CS120
Lab #4
Due at the end of lab.
For this lab you will be modifying the Calculator program from
Chapter 4 of the text.
A version of the code will be posted on the course schedule. Note that
this calculator program is not the same as the one from
previous assignments - it uses a series of functions.
To complete the lab make the following
modifications:
-
Fix the minor, but annoying, problem that when the user exits,
the program reprints the last answer.
-
Currently, the program just prints the answer to each of the user's
problems. Change the output so that the program prints the whole problem
as a mathematical expression. For example, if the user asks for the sum
of 4.5 and 1.3, the program currently prints:
answer = 5.8
change it to print something like:
4.5 + 1.3 = 5.8
- Add a subtraction operation to the calculator.
- Add an operation that calculates the
surface area of a right circular cylinder.
This calculation
should be performed in a separate function, not in the main() function.
- Add an operation that calculates the
volume of a right circular cylinder.
This calculation
should be performed in a separate function, not in the main() function.
- Add an operation that calculates the
surface area of a right circular cone.
This calculation
should be performed in a separate function, not in the main() function.
- As always, add a comment block to the beginning of the program with your
name, section number, date, and the lab number.
Turn in:Use the script command to demonstrate how your program runs.
Place the output from the script command into file named Lab4output.txt
In the sample output, make sure you run your program multiple times to show how it behaves with different inputs.
Turn in a copy of your program code and the Lab4output.txt file to Canvas.