Assignment 05

start main

greet user

loop on

present menu

switch (menu_choice)

case

gather necessary user input

call Rigor function

case

gather necessary user input

call Algor function

. . .

default

invalid choice

present results

end loop

signoff message

end main

And here are descriptions of the functions that we want you to have: (note: I prefer to indicate a function by putting () after the name. Just because there may not be anything in the parentheses, doesn't mean there aren't any parameters.)

  • a greeting() function that returns nothing and is passed nothing. It will display a message to the user stating what program they are using.

  • similarly, a signoff() function.

  • a present_menu() function that will return a character and is passed nothing. It will present the menu shown above and prompt for and read in a char response indicating the user's (supposed) response. No input "cleansing" is done here. An invalid choice should be handled by the switch in main().

  • a rigorMortis() function which will return an int and is passed a float and two bools. The float is the body temperature; the first boolean value indicates whether the victim was ill at the time of death, and the second boolean indicates whether the victim was a computer scientist. All this information is gathered from the user if option 1 is chosen and then passed to this function. The function will calculate and return the TOD using this formula:

Details: First, here is pseudo-code for your main function:

Ye shall use a switch-case statement to handle the choices made by the user. And each case, appropriate output is determined and presented to the user and the menu is again presented. The Quit option will terminate the program.

6. QuitMortis

5. StomachMortis

4. VitreousPotassiumMortis

3. OccularMortis

Due: Wednesday, March 4, 2015 at noon 100 points

For this assignment, you will submit a single C++ compilable file containing a program written in C++. Your function prototypes will precede that main function and your function definitions will be placed after the main function. Use ONLY ONE FILE for this assignment. Of course, you will submit in the usual (correct) way.

Background: Mr. Jackson, our forensics hero, (you can call him "Action") was so pleased with your last menu driven program that he wishes you to do much the same with this next exercise. You will write a menu-driven program, but this time you are going to use functions within the implementations of your menu choices. This program will help Action to determine the time of death (TOD) of a victim. The TOD will be based on (very) scientific results well known in the field and published in the most reputable journals.

Since this is your first program using functions, we will lay out for you the functions we require you to have. If you wish to include others, you may do so, but make special comments in your code telling the grader what you are doing and why.

Specifications: In general, your program will loop the presentation and functionality of the menu that looks like this:

TOD Determination Options

--------------------------------

1. RigorMortis

2. AlgorMortis

  • TOD = (98.6 - bodytemp) / 2.1 + 1.5 (if ill) - 2.5 (if computer scientist)* et = 3a algorMortis() function which will return an int and is passed a float. The float passed is the body temperature as measured by inserting a thermometer in the victims bellybutton. And the formula for this:

    • TOD = (98.6 - bodytemp) /1.5

    • et = 2

  • a occularMortis() function which will return an int and is passed two bools. The first boolean value indicates whether occular discoloration has occurred; the second to indicate whether the eyes are bulging. TOD returned will be determined by this table:

              • no discoloration

              • not bulging

              • 4

              • no discoloration

              • bulging

              • 16

              • discolored

              • not bulging

              • 7

              • discolored

              • bulging

              • 24

    • et = 5

  • a vitreousPotassiumMortis() function which will return an int and is passed a single float representing potassium concentation:

  • TOD = (17.14 * potassiumConcentrationFromEyeFluid) - 39.1, 3 <= concentration <= 7

  • et = 4

  • a stomachMortis() function which will return an int and is passed a single integer that represents the number of shots of whiskey the victim has in his/her stomach. The computation of TOD is

  • TOD = 10 - num_shots**

  • et = 0

  • a presentResults() function that will return nothing and is passed two integers, the TOD and the et. It will display to the screen a message stating the likely time frame of the TOD. It should read like this:

    • Time of Death of the victim is estimated between TOD - et and TOD + et hours before discovery.

    • Thus, the first int passed will be the value returned by one of the "mortis" functions above, and the second int is the error tolerance (et) of that estimate. That value is also determined by the type of the "mortis" function, and is listed above as et for each mortis function.

In all cases above, if the error tolerance (et) puts a lower bound negative, that should be changed to 0. For example, if the TOD is 2 but et is 4, then the TOD estimate should be reported as 0 to 6 hours. Also, be sure, in this and every assignment, that you check the range of input for any inputs checkable. And, you will notice that some of the mortis functions return an int, but calculate a float. So, in each of these cases, you will round the resulting float calculated. We will show you in class how to round. In short, add .5 and chop.

When you submit: Enter the following choices

  • choose option 1 and enter values to indicate temp is 80 degrees, is ill, and is computer scientist

  • choose option 2 and enter body temp 97

  • choose option 3 and enter information to indicate bulging and discolored eyes

  • quit

As always, be sure ask if you have any questions.

*This adjustment must be made in the case that the victim is a computer scientist. You see, computer scientists are so cool that TOD would be thrown off by their coolness. So, one must add back that coolness factor, like, to make up for how much cooler they are than everyone else.

**Notice that when the number of shots reaches 10, TOD is 0 indicating that the victim is not really dead, but just well preserved...pickled, as it were!

***No dead people were harmed while preparing this web page.