CSC 101 Programming Assignment 2:
Enhancements to Making Change;
Advanced Numeric Computations
This assignment has two parts. Part A involves some simple enhancements to Programming Assignment 1 from last week. Part B is a new program involving some more advanced numeric computation with real numbers.
Update the solution to Programming Assignment 1 as follows:
To accomplish the first of these modifications, you will need to change some of the integer variables used in the solution to Program 1 to floating point variables. To add the additional denominations of change, you need to add new C++ code based on computations for the lower denominations. Finally, to control the format of your output, you can use the setprecision output manipulators described on pages 111-112 of the book.
Acme Storage Containers, Inc. specializes in storage containers "of all shapes and sizes". They rent the containers for use at construction sites or any other kind of location that needs temporary storage. When a container is returned by the renter, it must be fumigated and repainted inside and out.
The available container shapes are rectangular, hemispheric, cylindrical, and conical. They are available in a range of sizes. In order to determine how much fumigant and paint to buy for a returned container, the volume and surface area of the container must be computed. Your program will perform these computations.
The program inputs two real numbers that specify the base and height dimensions of a container. For a rectangular container, the base is the length of one of the square sides of its floor; for the other three shapes, the base is the diameter of its floor. For all four shapes, the height measure is how tall the container is from floor to top.
The program outputs eight real numbers for the volume and paintable surface areas of each container shape. The paintable surface area is the total surface area both inside and out, minus the area of the bottom (one side) of the floor. For the purposes of these computations, you may assume that the thickness of the walls is negligible, so that both the inside and outside surface areas are the same. The output values should be ordered as follows:
Volume of rectangular container Paintable surface area of rectangular container Volume of hemispheric container Paintable surface area of hemispheric container Volume of cylindrical container Paintable surface area of cylindrical container Volume of conical container Paintable surface area of conical container
Test your programs with enough sample inputs to convince yourself that they work properly. In providing test inputs for Part A, you may rely on the original assumptions from Assignment 1 to be true (i.e., no negative inputs and amount tendered >= purchase amount). For testing Part 2, you may assume that all inputs are positive real numbers.
For Part A, you should start work from your solution to Programming Assignment
1. If you did not complete Assignment 1, you can use Fisher's solution, in the
file
Be sure to update the documentation from Program 1 as necessary. E.g.,
since Program 2A uses real numbers instead of integers for input, the comments
that describe the inputs should refer to real numbers instead of integers.
~gfisher/classes/101/solutions/program1.cpp
For Assignment 2 Part B, you must develop your solution by yourself, from scratch. Be sure to include all necessary documentation, i.e., top-level description, variable comments, and in-line code algorithm comments.
The C++ features necessary to complete this program are presented in
You must turn in two separate programs for this assignment, one for Part A and the other for Part B. Use the same electronic turnin procedure as you used for Programming Assignment 1, with the following appropriate changes to the names of the assignment and the filename:
names of this assignment: program2a and program2b
names of files: program2a.cpp and program2b.cpp