Kyle’s calculator program should allow a user to enter in numbers to either add or subtract. After each calculation, the program should store the previous result and allow the user to either add more to it or subtract from it. Here is an example of how the program should operate:
******************************************
Welcome to the simple calculator program!
This program will do simple addition and
subtraction. Math is fun, so enjoy!
******************************************
Please enter the first integer: 42
Please select a math function to perform ("+" = Addition, "-" = Subtraction): +
Please enter the second integer: 17
The result is 59
Would you like to continue calculating? (Y/N): y
Please select a math function to perform ("+" = Addition, "-" = Subtraction): -
Please enter the second integer: 34
The result is 25
Would you like to continue calculating? (Y/N): n
As long as the user answers either ‘Y’ or ‘y’ to the continue question, the program should continue calculating based on the last result. Help Kyle by fixing all of his coding mistakes so that his program will successfully compile and run as outlined above. Be sure to make comments in the code to highlight where Kyle went wrong.
0 comments