Due: Friday Feb. 14, 2014
Points Possible: 100 pts
Be sure that only the file you want to submit is in that directory - make a directory for every assignment! Remember that the submit system will deliver every .cpp file in the current directory to me, so you should only have the file for hw 3 in that directory. Name your file a meaningful name and give it a .cpp extension since you will be compiling it. Also, make sure that you compile and run your program using the GNU (g++) compiler before submitting to make sure that it will work for the submit script.
Instructions: For this assignment, you will submit a single C++ compilable file containing a program written in C++. Remember, to electronically submit a file for this course, first change to the directory in which the file resides and then type in, at the UNIX prompt, the command:
cssubmit 53 section_letter assignment_number
Ralph creates his science projects by gathering things1 on his walk to school, throwing them in a paper bag, and sometimes combining them with his usual nutritional supplement, glue. He also brings money with him to school to be able to buy stuff2 from Bart's Better Chemistry Storehouse (don't even ask!) to add to the bag of ingredients. Miss Hoover scores Ralph's projects on a sliding scale from 0 to 10. For any particular project, she will look in the bag and then blurt out a number she thinks is commensurate with his efforts. Let's refer to this score as the Hoover Score, or HS for short. For now, any score less than 2.0 is an 'F', 2.0 <= HS < 3.0 gets a 'D', 3.0 <= HS < 4.0 receives a 'C', 4.0 <= HS < 5.0 is rewarded with a 'B', and 5.0 or higher is an 'A'. Of course, that could change next month. And if that isn't hint enough to have you think CONSTANTS, then maybe this hint about CONSTANTS will make you think about CONSTANTS as you write your code that should include CONSTANTS.
Background: So, you're working to help out our little client, Ralph. Now Ralph Wiggum isn't too bright, as you have seen and will experience further. One of Ralphie's problems is that he thinks that every Friday is "Science Project Day". With this belief system in place, Ralph shows up to Miss Hoover's class each Friday with a ... science project. Miss Hoover has given up trying to convince him that it isn't so, and just gives him a grade, throws away the project, and sends him to his seat. Ralph wants you write a program he can use to predict the grade Miss Hoover would give a science project. He'll use the program over and over again thinking that it will help him figure out what makes a good project.
Specifications: Your program should start by prompting the user (again, presumably Ralph) for the amount of trash (poundage) he would have picked up along the way to school and how much money he would have with which to buy stuff. If the answer is 0 in both cases, then Miss Hoover would give him a HS of 1 (a nonzero value because she doesn't want to destroy Ralph's self-esteem), and so your program should do the same. When that happens (having nothing to show), Ralph would often start to whimper and cry, which would result in Miss Hoover tripling his HS to shut him up. So, your program will need to prompt him to see if he plans on crying and triple his HS if he responds affirmatively. Otherwise, having arrived to class with at least some trash and/or money, he would buy what he can from Bart. Bart sells toxic chemicals in 1-pound bags for $2. Ralph would buy all he can, and spend the leftover change on something to stick in his nose. So, your program needs to compute what he could buy with the money he says he has. Your program would then need to prompt Ralph to know if he is hungry or not, whether or not his bag of trash contains something that is glowing (perhaps a discard from the nuclear plant), and whether or not he would have a bottle of glue with him. If he is hungry and he has glue, he will eat 1/4 of the contents of the bag. And if there is something glowing in the bag, he'll eat another 1/4 of it. But in this last case, he would always puke back up 1 lb into the bag, adding to the scientific value of the project. Now, if he only has glue but isn't hungry, then he will most definitely pour the glue (1/2 lb.) into the bag to "cement his success" for the best science project in the class.
Finally, having tallied the weight of the contents of the bag, your program assigns the HS as that weight. For example, given a set of inputs, if the weight is 3.4 lbs, his HS is 3.4. The HS value given and the letter grade scale noted above will determine Ralph's grade. After your program has reported (output) the grade for the project, it should then prompt the user if he/she would like to repeat the entire process. If the response is to decline, then the program ends. If the response is affirmative, then the science project review/grading process is to begin anew.
1Rocks, sticks, lizards (dried and living), mice, tar, flowers, plastic army men, gum, ...
When you submit: As usual, you will submit using the submit system. During the submission process, the program will run and you will need to input values. The inputs shall be:
5.6 lbs of trash
$5.50 in his pocket
yes, he is hungry
yes, he has a glowing item in the bag
yes, he has glue with him
choose to repeat (make your loop repeat the process)
0 lbs. trash
0 cash in the pocket
he will cry
quit
As usual, if you have any questions about this assignment, be sure to present your science project to your instructor along with your questions.
Be sure to:
use good variable and constant names
use constants. I can see needing many constants in this program
format your code nicely so it's easy to read
comment code where necessary
structure your logic to be efficient