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

Write a Program to implement a Math Calculator as below:

Declare three floating-point 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 Values for number1 and number2

3. Write a Switch statement to do the following

Case a:

result = number1 + number2;

break;

Like this do all the cases

4. Then ask the user to enter a value for loopControl

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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!