I need to create a basic calculator that handles specific bad output situations
ID: 3647191 • Letter: I
Question
I need to create a basic calculator that handles specific bad output situations namely where a user enters data that is non-integer or non-numerical. In which case the program terminate abnormally. Otherwise ending after a single operation.I need to
1. Handle the bad input situation with the use of exception handling,
Bad input that should cause an exception to be thrown are:
b. Non-numeric operands
c.Unknown operator not any of the four basic operations
d. Division by zero.
The program should not terminate but should inform the user of the specific error and should re-request the input value which was in error
2. Correct operation will include repeated operation so that the user may perform many operations without restarting the program after each.
The program should not terminate but allow the use to recover with a corrected value./ values. This should be done with the use of exception handling.
The program should not terminate abnormally under any circumstances.
Please write out this program and tell me what you did.
Explanation / Answer
#include using namespace std; int main() { double a, b, c; // Request two numbers from the user cout a; cout > b; // Multiply the numbers and display the result c = a * b; coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.