Post-lab - Lab (5)


To maintain one's body weight, an adult human needs to consume enough calories daily to (1) meet the basal methabolic rate (energy required to maintain body temprature, ect.), (2) account for physical activity such as exercise, and (3) account for the energy required to digest the food that is being eaten. For an adult that weights P pounds we can estimate these calories requirements using the following formulas:

1. Basal Metabolic Rate: Calories required = 70 * (P / 2.2) * 0.756

2. Physical Activity: Calories required = 0.0385 * Intensity * P * Minutes

Here, Minutes is the number of minutes spent during the physical activity, and Intensity is a number that estimates the intensity of the activity. Here are some sample numbers for the range of values:

Activity                Intensity

Running 10 mph          17

Running 6 mph            10

Basketball                    8

Walking 1 mph            1

3. Energy to Digest the Food: Calories required= TotalCaloriesConsumed * 0.1
In other words, 10% of the calories we consume goes towards digestion.

Write a program that shows a menu with the names of 3 functions described above. According to the selection of the user, the program computes either the Basal Metabolic Rate or the Calories required for Physical Activity, or the calories required to Digest the Food. Allow the user to repeat the selection process as many times as desired. The function that computes the calories required for the basal metabolic rate, takes as input a parameter for the person weight. The function that computes the calories required for the physical activity, takes as input parameters for the intensity, weight, and minutes spent exercising. The function that computes the calories required for the energy to digest the food, takes as input a parameter the total calories consumed per day. You are also required to overload the function for the Basal Metabolic Rate calculation so that it may take as input a parameter for the person weight that is either an integer or real number. Ask the user if an integer or a real will be provided and call the appropriate function. Call the program Calories.cpp.

Before you start writing any code, be sure to design your solution. Break the problem in small tasks and focus on one task at the time. Initially, focus your attention to the main function, the input output communication to the design of the menu. Design each funtion in a way that do not compute anything at all (we call these functions stubs) and call them from the main. When you have completed the main then write the implementation of each function, one at a time.

Extra Credit (10 points): Use these functions in a program that inputs a person's weight, an estimate for the intensity of physical activity, the number of minutes spent performing the physical activity, and the number of calories in one serving of food. The program should then calculate and output how many servings of that food should be eaten per day to maintain the person's current weight at the specified activity level. The computation should include the energy that is required to digest the food. You can find estimates of the caloric content of many foods on the web. For example, a double cheesburger has approximately 1000 calories.

 

Instructions to return your lab to the teacher: (5 points penalty if instructions are not followed appropriately)

  1. Be sure you return all the printed files where you have written all your answers. These are the answers to 5.3, 5.4, 5.6, and 5.8.
  2. Transfer ONLY the source files you have written from loki to your local Windows machine and collect them in a  folder called YourLastNameLab5 (ex. AGuercioLab5). Be sure you did not copy any executable file in this folder. If you did, please remove it from the folder.
    The files to be zipped are:

    Exercise 5-2: 
    ex52.cpp
    Exercise 5-5:
    ex55.cpp
    Exercise 5-7:
    ex57.cpp
    Post Lab:
    Calories.cpp

    DO NOT INCLUDE: Exercise 5-1:

    ex51.cpp
    Exercise 5-6:
    ex56.cpp
  3. Now exit from the folder, right click on the folder and choose WinZip-->Zip and e-mail. This action will pack your folder and attach it to an e-mail. You can use a Rar Program if you have that program instead of the Zip program.
  4. Send the e-mail to kschaffe@kent.edu with the subject CS23021 Lab 5 Submission.
  5. Send your e-mail before the deadline to receive full credit.
ATTENTION: Return a printed copy of the source files to your instructor as well.

Congratulations! You have completed another Lab of CS I !! :-)