Assignment 02

Due: Friday, Feb. 7, 2020, at noon, 100 points

For this assignment, you will submit a single C++ compilable file containing a program written in C++. We suggest (strongly) that you make a directory for every assignment! 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.

Background: Groundskeeper Willie, keeper of the grounds for Springfield Elementary, quite often has to dispose of dead 'possums. But he always has trouble choosing the instrument to use to transport them (to the principal's car, of course). He normally picks up the 'possum with one of his many pitchforks. He has several, like 12 of them, all with different length handles. They range in length from short to longer to even longer; then there's really long. He wants you to write a computer program that will calculate handle length of the appropriate pitchfork, and then tell him which fork to use. How he chooses the tool-o-choice is dependent on the following:

  • the weight of the 'possum, wt: a real number that ranges from 2.7 (juvenile 'possums) to 45.5 (mondo 'possums!)

  • the stink factor of the carcass, SF: an integer from 1(kinda stinky) to 10 (really stinky)

  • the length of the animal's tail, L: a real number between 4.5 and 15

  • the International Dead Infectious Opossum Threshold Score (IDIOTS), an integer currently set by the Dead Opposum Standards Committee to be 8.

  • barometric pressure, BP (well, that's logical)

The formula for calculating the length of the fork handle is as follows:

length = (SF/IDIOTS) x (3L + wt) + 30(SF/BP)

Once length is computed, your program will need to figure out which of his 12 forks he needs to use. They are numbered 1 - 12 and are used in the following way:

  • fork #0 has handle 5" long and is used when the job requires a handle length between 0 and 9.999999 inches

  • fork #1 has handle 15" long and is used when the job requires a handle length between 10 and 19.999999 inches

  • fork #2 has handle 25" long and is used when the job requires a handle length between 20 and 29.999999 inches

  • fork #3 has handle 35" long and is used when the job requires a handle length between 30 and 39.999999 inches

  • etc

So, you see, if you compute the handle length to be, say, 48.2, then that indexes to 4.

is not user-friendly. Notice that there is no label on the number, no words explaining what has been done, etc. Here's a better output format: For the following inputs: wt: xxxx bar pressure: yyy stink: zz tail: vv handle length is: wwww and fork number is: r

You get the idea. (Of course, you will not output letters. You will output numbers - of the right type!)

NOTE: You are NOT to use decision-branching in the solution. That is, you may NOT use the if-else or the switch-case statements.

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.

Note: Don't make the mistake of using identifiers (the name for a value) in your programs that are not suitable, even if the "boss" (whoever it is giving you this assignment) has used them. YOU are writing the code, so YOU will name the variables and constants.

When you submit this program, the graders will run a script that automatically inputs appropriate values for the variables in the assignment. But for this process to work, you MUST prompt for user input in the correct order. So, when writing your code, prompt for and read in the vaules for

  • stink factor, then

  • barometric pressure, then

  • tail length, then

  • weight of the animal (that would be 'possum)

If you change the order above, your program will not work according to the grading!!

As always, if you have questions, don't hesitate to ask your instructor. And remember discord!

So, you will begin your program by greeting the user. Then, you need to prompt for and read in the relevant information about the offending animal from the user for the calculation(s). After that, you will output an echo of the input values, the calculated handle length, and then the fork number. You need to make your output "user friendly". Output such as

6