Question: Please write a C++ program that can perform the following 6 operators for 2 numbers: N1 and N2. You need to prompt the user to
Please write a C++ program that can perform the following 6 operators for 2 numbers: N1 and N2. You need to prompt the user to enter the first number, an operator, and the second number. Please see the sample test below to design your application program properly. This program is a calculator for users to enjoy. You must thank the user and stop your program when the operator entered is @.
The 6 valid operators for this simple calculator are as follows:
- + 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 of N1 by N2. If N2 is zero, please
say The second number cannot be zero!, else result = (N1 / N2).
- ** for power N2 with base N1 (i.e., N1N2). Therefore, result = ( N1 ** N2 ).
- % for division remainder (i.e., modulus) of N1 by N2. If N2 is zero, please
say The second number cannot be zero!, else result = ( N1 % N2 ).
- @ for stopping the calculator game. You must thank the user before leaving this program.
- Otherwise, please say Sorry, ____ is not a valid operator!. Please show this invalid operator.
===========================================================================.
The following is a sample standard test, which must be your test case #1. You must also do test case #2 and test case #3 with different set of data. Each of your test case must cover all 6 valid operators (at least once for each) plus an invalid one.
Welcome to the the program of "Your firstname Your lastname" !!!
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
The second number cannot be zero!
Enter your first number: 99
Enter your operator: /
Enter your second number: 8
Result: 99.0 / 8.0 = 12.375
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
