Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Strategic management concepts

Authors: Fred david

13th Edition

9780136120988, 136120997, 136120989, 978-0136120995

Students also viewed these Databases questions