Please Write C Program Using Modular Programming Techniques Perform Following 6 Operators Q43788873
Please write a C++ program (using modularprogramming techniques) that can perform the following 6 operatorsfor 2 numbers: N1 and N2. You need to prompt the user to enter thefirst number, an operator, and the second number. Please see thesample test below to design your application program properly. Thisprogram is a calculator for users to play andenjoy. You must thank the user and stop your programwhen the operator (entered by the user) is ‘@’.
The 6 valid operators for this super calculator are asfollows:
- + for addition of N1 and N2. Therefore, result= (N1 + N2).
- – for subtraction of N2 from N1. Therefore,result = (N1 – N2).
- * for multiplication of N1 with N2. Therefore,result = (N1 * N2).
- / for floating-point division ofN1 by N2. If N2 is zero, pleasecontinue the loop asking user to
enter a non-zero value for N2 until you receiveone. Then, result = (N1 / N2).
- ** for power N2 with base N1 (i.e.,N1N2). Therefore, result = ( N1 ** N2 ).
- % for division remainder (i.e., modulus) of N1by N2. If N2 is zero, please continuethe loop
asking user to enter a non-zero value for N2 until you receiveone. Then, result = ( N1 % N2 ).
- @ for stopping the calculator game. You mustthank the user before leaving this program.
- Otherwise, please continue the loop asking userto enter a valid operator until you receive one. Then,apply the operator to N1 and N2 to show theresult.
===========================================================================.
Modular Programming Techniques: Please define the followingfunctions for your main program to call.
- Add( N1, N2)
- Subtract (N1, N2)
- Multiply (N1, N2)
- Divide (N1, N2)
- Power (N1, N2)
- Modulus (N1, N2)
- GetValidOp (N1, N2) : get a valid operator, and then call oneof the above 6 functions.
===========================================================================.
The following is a sample standard test, which must be yourtest case #1. test case must cover all 6 validoperators (at least once for each) plus an invalid one.
Welcome to the program of “your name” !!!
Enter your first number: 10
Enter your operator: +
Enter your second number: 90
Result: 10.0 + 90.0 = 100.0
Enter your first number: 55
Enter your operator: –
Enter your second number: 49.5
Result: 55.0 – 49.5 = 5.5
Enter your first number: 12
Enter your operator: *
Enter your second number: 55
Result: 12.0 * 55.0 = 660.0
Enter your first number: 99
Enter your operator: /
Enter your second number: 0
Enter your second number which cannot be zero:0.0
Enter your second number which cannot be zero:0.
Enter your second number which cannot be zero:7
Result: 99.0 / 7.0 = 14.1429
Enter your first number: 99
Enter your operator: /
Enter your second number: 8
Result: 99.0 / 8.0 = 12.375
Enter your first number: 2
Enter your operator: **
Enter your second number: 12
Result: 2.0 ** 12.0 = 4096.0
Enter your first number: 99
Enter your operator: %
Enter your second number: 0
Enter your second number which cannot be zero:0.
Enter your second number which cannot be zero:0.00
Enter your second number which cannot be zero:7
Result: 99.0 % 7.0 = 1.0
Enter your first number: 99
Enter your operator: %
Enter your second number: 8
Result: 99.0 % 8.0 = 3.0
Enter your first number: 99
Enter your operator:
Enter your second number: 5
Enter a valid operator: ^
Enter a valid operator: ~
Enter a valid operator: %
Result: 99.0 % 5.0 = 4.0
Enter your first number: 0
Enter your operator: @
Enter your second number: 0
Thank you for using program designed by”you”
Expert Answer
Answer to Please write a C++ program (using modular programming techniques) that can perform the following 6 operators for 2 numbe…
OR