Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Math.cpp: (30 points) You need to help your nephew with his math skills Provide

ID: 3607610 • Letter: M

Question

Math.cpp: (30 points) You need to help your nephew with his math skills Provide a menu of math options (add, multiply, and subtract) Randomly generate the numbers.. allow your nephew to set the range for the numbers. Allow your nephew to enter his answer. Tell him if he is correct. tell him if he is not correct and provide the correct answer. Repeat the math drill until your nephew indicates he doesn't want to continue. Your name, date, and program identification at the top of the .cpp file (2) Comments (clear, useable, representative of algorithm) (10) Functions (6) Loop (4) Communication with user and clarity of display (spacing, ease of reading, decimal points, etc) (10) __ Address invalid data (4) Program meets all specifications (30)

Explanation / Answer

#include<iostream>

#include<stdio.h>

#include<stdlib.h>

using namespace std;

int main()

{

float x, y, z,w;

char choice, ch;

cout<<"simple Math operations";

do

{   

cout<<"1.Addition ";

cout<<"2.Subtraction ";

cout<<"3.Multiplication ";

cout<<"4.Division ";

cout<<"5.Exit ";

cout<<"Enter Your Choice : ";

cin>>choice;

switch(choice)

{

case '1' : cout<<"please enter two numbers : ";

cin>>x;

cin>>y;

cout<<" please enter the answer ";

cin>>w;

z=x+y;

cout<<" addition of given numbers = "<<z;

if(z==w)

cout<<" So your answer is correct ";

else

cout<<" your answer is not correct ";

break;

case '2' : cout<<" Please enter two numbers : ";

cin>>x;

cin>>y;

cout<<" please enter the answer ";

cin>>w;

z=x-y;

cout<<" subtraction of given numbers = "<<z;

if(z==w)

cout<<" So your answer is correct ";

else

cout<<" your answer is not correct ";

break;

case '3' : cout<<" Please enter two numbers : ";

cin>>x;

cin>>y;

z=x*y;

cout<<" please enter the answer ";

cin>>w;

cout<<" multiplication of two numbers = "<<z;

if(z==w)

cout<<" So your answer is correct ";

else

cout<<" your answer is not correct ";

break;

case '4' : cout<<" Please enter two numbers : ";

cin>>x;

cin>>y;

z=x/y;

cout<<" please enter the answer ";

cin>>w;

cout<<" division of two numbers = "<<z;

if(z==w)

cout<<" So your answer is correct ";

else

cout<<" your answer is not correct ";

break;

case '5' :cout<<" You cannot continue the program ";

exit(0);

break;

default : cout<<"Please enter a valid coice!!";

break;

}

cout<<" ------------------------------------ ";

}while(choice!=5 && choice!=getchar());

}

output:

simple Math operations1.Addition                                                                                               

2.Subtraction                                                                                                                  

3.Multiplication                                                                                                               

4.Division                                                                                                                     

5.Exit                                                                                                                         

                                                                                                                               

Enter Your Choice : 1

please enter two numbers :                                                                                                     

23                                                                                                                            

45                                                                                                                             

                                                                                                                               

please enter the answer

45                                                                                                                             

                                                                                                                               

addition of given numbers =                                                                                                    

68                                                                                                                             

your answer is not correct

------------------------------------                                                                                           

1.Addition                                                                                                                     

2.Subtraction                                                                                                                  

3.Multiplication                                                                                                               

4.Division                                                                                                                     

5.Exit

Enter Your Choice : 5                                                                                                          

                                                                                                                               

You cannot continue the program