Assignment 03

Due: Thursday, Sept. 15, 2011, 12:00 noon, 100 points

For this assignment, you will submit a single C++ compilable file containing a program written in C++. Remember, to electronically submit a file to 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

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.

Background: Groundskeeper Willie was really impressed with your coding for this pitchfork problem. This, of course, is a lie; he thinks "C++" is E. But no matter, he wants you to now write a program that will help him decide whether/how to "work" while at the school. More to the point, he wants the computer to tell him how to avoid work. So, you will write a program that will input various parameters and use them to tell Willie or anyone in his job what to do dependent on those input values.

Specifications: Your program should first prompt for and input the user's name for subsequent prompts and output (use the name at least once, perhaps not all prompts). It should then prompt for and read in, in whatever order you deem most efficient, information to make the correct recommendation to the user about how he/she/it should behave according to the following:

  1. The work recommendation will depend on the user's motivation, indicated by levels: a, b, c, d, and e. If motivation is at level e (which stands for "elevated slothfullness"), then the recommendation should be "stay in bed and skip work".

  2. If the motivation is input as d (standing for "don't plan on work from me"), then the user is recommended to

    • hide in the toolshed if it rained the night before

    • hide in the hedge if it didn't rain the night before

  3. If the motivation level input by the user is c (c is for "can't get good help no more!"), then

    • lean on a rake should be the recommendation if it rained less than 1.5 inches, and

    • lean on a broom (presumably inside) if it rained more than that

  4. If the user has b ("basicly good worker") level motivation, then the recommendation is to:

    • "get on hands and knees and scrub floor" if either the number of children present is less than the number of adults present OR if Superintendent Chalmers is present.

    • "mop the floor" otherwise

  5. An a-level motivation is truly impressive! if that is the input value, then

    • if the user has between 5 and 10 gals of gas and it rained less than 1/2 in the night before, they should mow the grass

    • if they have more than 10 gal of gas and it rained less than 1/2 in, they should get on the tractor and do laps around the school (looking really busy!)

    • and assuming less than 1/2 in rain and less than 5 gal of gas, they should go get more gas

    • if it rained more than a 1/2 in,

      • having less than 5 gal of gas, they should burn old text books from the 1940's

      • otherwise, use that gas to clean the bathrooms

As usual, make your output user-friendly. Write your code as efficiently as possible: meaning it should not do anything unnecessarily. Be sure to use constants where appropriate.

Remember: When writing your code, be sure to:

  • Declare your variables with the APPROPRIATE type.

  • Use meaningful variable names.

  • Use proper spacing for indentations.

  • Use constant declarations where appropriate.

  • Include the comment block at the head of your file.

  • Comment code that needs it.

  • Be literate in your welcoming/signing-off messages and prompts and output.

When you submit this, and all subsequent programs for this class, cssubmit will compile and run (assuming it compiles) your program during the submission process. Thus, when you submit, you will have to enter inputs as a user of the program. Now, in order to make the output uniform for the grader and to keep her/him sane, ALL OF YOU will enter the same information. For this assignment, it is:

  • a funny name of your choosing (remember: no spaces in the name)

  • level a motivation

  • .25 inches of rain the night before

  • 7 gals of gas on hand

As always, if you have questions, don't hesitate to ask your instructor or the LEAD tutor.