Question: C++ Write a Program to implement a Math Calculator as below: Declare three integer variables: number1, number2 and result Also declare two character variables operation

C++
Write a Program to implement a Math Calculator as below:
Declare three integer variables: number1, number2 and result
Also declare two character variables operation and loopControl
The variable operation has five valid input values: a (for addition), s for subtraction, m for multiplication, d for division, and r for remainder.
The value of loopControl can be y or n to continue the loop or not.
Set the loopControl initial value to y
Then write a while loop to check if loopControl equal to y or Y, then inside the loop do the following:
1.Display a menu as below:
Enter a for Addition
Enter s for Subtraction
Enter m for Multiplication
Enter d for Division
Enter r for Modulus
2. Get value for operation
3. Get Values for number1 and number2
4. Write a Switch statement to do the following
Case a:
result = number1 + number2;
break;
Like this do all the cases s, m, d, r , default case should display not a valid operation
5. Display the result, properly
6. Then ask the user to enter a value for loopControl
Exit from the loop
Run the program with valid data.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To implement a math calculator in C we can follow the instructions provided Heres a stepbystep guide to writing the complete program Step 1 Include Required Headers First include the necessary header ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!