The Right Cylinder Glass Company manufactures only one product: a perfectly cylindrical blue drinking glass. All glasses are custom-made, according to a customer's individual preferences in size and thickness.
In the past few months, however, RCGC has been losing money due to flaws in their manufacturing process. It seems they just can't manage to produce the right of amount of glass to properly fill an order. It's always either too much glass or too little, and both of these cost money.
RCGC has hired you to solve this problem. Your job is to write a program, glassvol, which prints out the amount of glass, in cubic inches, necessary to fill a given order. Each time a user runs your software, she should be prompted for the height, width, and wall-thickness of each glass (given in inches, to the nearest 1/100th of an inch), and the number of glasses in the order (an integer, obviously). This is sufficient information to compute the answer.
For example (user input is in italics and underlined),
How tall is each cup? 8.2 How wide? 2.2 How thick? 0.1 How many cups in this order? 1000 You will need 5723.98 cubic inches of glass to fill this order.
Your program will be judged primarily on its correctness. In particular, the program must compile. Programs that do not will receive a severe grade penalty. Over and above this is the requirement of correct behavior: the cubic volume reported must be correct.
Third, there is presentation: prompts should be formatted neatly (exactly matching the example here is good).
Finally, your program will be judged on elegance and adherence to the principles of good programming style. Elegance means that there should be nothing there that isn't necessary for the computation: all variables should have a use, as should all assignments to those variables. Style refers to the proper use of indentation, information variable names, documentation with comments, and other matters of readability. For a discussion on the elements of programming style, see pages 24-27 of your text and/or The Elements of C++ Style (available on reserve in th Science Library).
To get you started, observe that once we know the height, width, and wall-thickness of the glass, we can compute:
Even discounting input and output, this already identifies three subproblems into which we can decompose the larger one. (They are closely related, of course, and we shall see in a few days how to capitalize on this for code re-use.) See any geometry textbook for the necessary formulae.
The fourth sub-problem is I/O. While we will have covered everything you need by the end of Tuesday's class, you might also look at the file guessAge.cpp, available in the CIS 122 Code directory at
This gives an example of the kind of I/O you'll need to master for this assignment.const double PI = 3.141593;
int x = 0; x = 3.99;the decimal portion will simply be truncated. x will have the value 3, not 3.99 nor 4.
Other answers to FAQs as they appear. I'll post announcements if anything new shows up.