Return To CS 110 Home

Colour Theme   Font Size Options
 
   
   
   
Exercise 3

Metabolic Power Exercise

Biologists are concerned with computing the metabolic power of mammals and reptiles. For example, a hibernating ground squirrel is contained in an air tight chamber. The mass of the squirrel is 30 grams. The ambient temperature inside the chamber is 5 degrees Celsius. The chamber pressure is 756 mmHG. The concentration of oxygen in ambient air is 0.2095, which is being pumped into the squirrel's chamber at the rate of 6000 mL/hr. You record the concentration of oxygen after passing through the chamber (i.e., safely assuming that the hibernating squirrel is respiring albeit very slowly and thus taking oxygen out of the system) as 0.2092.

Please add code to template file ex3_metabolic.cpp in the replit team project or create it in your IDE.

 

Computing Metabolic Power

Computing the metabolic power involves five main steps.

Step 1. Declare the following six variables:

mass - mass in grams,
at - ambient temperature in degrees Celsius,
cp - chamber pressure in mmHG,
pre - concentration of ambient air (pre-animal),
post - concentration of ambient air (post-animal),
vaf - the rate in which oxygen is pumped into the chamber in mL/hr.

Step 2. Compute the volume of oxygen consumed (voc).

voc = vaf * (pre - post) / (1 - post).

Step 3. Correct voc to standard temperature and pressure (stp).

stp = voc * (cp / 760) * (c1 / (c1 + at)),

where c1 is the constant value 273 for correcting from voc to stp.

Step 4. Calculate metabolic power (mp) from stp.

mp = stp / (mass * c2),

where c2 is the constant value 0.179 for calculating mp from stp.

Step 5. Output the six input values and the mp.

 

Programming Exercise

Write a C++ program for a biologist that calculates and prints metabolic power.
  1. Include a void function, called getData(), that takes six arguments to input:
    • mass
    • at - ambient temperature
    • cp - chamber pressure
    • pre - concentration of ambient air (pre-animal)
    • post - concentration of ambient air (post-animal)
    • vaf - rate in which oxygen is pumped into the chamber
  2. Include a void function, called calcVOC(), that takes four parameters and determines voc.
  3. Include a value-returning function, called calcSTP(), that takes three parameters (voc,cp,at) and calculates stp.
  4. Include a value-returning function, called calcMP(), that takes two parameters (stp,mass) and calculates mp.
  5. Include a function, called printMetPower(), that takes seven parameters and prints an appropriate concluding message on the screen.
  6. Use function coding style as shown in lab: use function prototypes and use reference parameters only where necessary.
  7. Use meaningful variable names, proper indentation, and appropriate header and in-line comments.
  8. Use the output format and style shown in the sample run below.
Demonstrate that your program works using the squirrel example above.

 

Sample Program Output

This program computes the metabolic power of mammals and reptiles.
Please input the mass of the animal: 30
Please input the ambient temperature: 5
Please input chamber pressure: 756
Please input concentration of oxygen in ambient air (pre-animal): 0.2095
Please input concentration of oxygen in ambient air (post-animal): 0.2092
Please input the rate of oxygen: 6000

The mass of the animal is 30 grams.
The ambient temperature is 5 degrees.
The chamber pressure is 756 mmHG.
The concentration of ambient air (pre-animal) is 0.2095.
The concentration of ambient air (post-animal) is 0.2092.
The rate of oxygen is: 6000 mL/hr.

The metabolic power for this mammal or reptile is 0.4141.

 

When you are done: