CS120
Lab #3
Due at the end of lab.
For this lab you will be modifying the simple calculator program that
you wrote for Assignment 2. Please review that assignment for the full
requirements of that program. You should use your calculator program for this
lab.
To complete the lab, make the following modifications to the calculator program:
-
In the original version of the program if the user entered an illegal
value no operation was performed. Modify your calculator so that any time the
user enters an illegal operation an error message is printed and the user is
asked for a new value. This will require adding a loop containing a predicate that is based on the user's choice of operation.
-
In the initial version of the program it would perform one operation and then
exit. Change the program so that when it finishes a calculation it asks
the user if they want to perform another calculation. You can have the user
enter a 0 for no and 1 for yes, or use a char so they can enter the letter n or y.
-
Add an additional operation to the calculator.
This operation should calculate the sum of all
of the integers between the two numbers the user entered (truncating the numbers
if the user entered a real number). For example, if the
user entered 5.2 and 8.7 then the calculator should sum all of the values between 5 and 8 (i.e. 5 + 6 + 7 + 8). Remember that if you store a double value
in an int variable it is automatically truncated.
Turn in: Use the script command to generate the output of
the program showing all of the different functionality specified.
Turn in the source code of your program and a copy of the output of your program via Canvas.