# Specialization in psychology

A research institute specializing in physiology is conducting a study on the strain and effects of commuting trips done on a bicycle or walking. When the physiological strain of commuting trips has been studied, the results will be used in exercise prescriptions, which can then use commuting as part of an exercise regimen.

In this program you will write a C++ program to analyze a small subset of the data that has been collected.

INPUT: Redirect the input from the file HR.txt.

The file consists of three columns, with six lines of data for each person. The first line stores each person’s ID number (integer), clinically measured maximum heart rate (integer), and age (integer). The following five lines contain the day’s average commuting heart rate, maximum commuting heart rate, and exercise heart rate for five consecutive working days. Then, the six line sequence is repeated for the next person. At times the heart rate monitors reacted to nearby power lines or other objects, and gave false readings. These incorrect measurements were rejected and show up in the data file as
-1. On the days the person did not exercise, the exercise heart rate value is zero.

PROCESSING; Use precisely six parallel arrays: one for subject numbers and five for the calculated values as described below.

Using this information, calculate
1. Average of the average commuting heart rates for each person.
2. Number of days that the person exercised on his/her own.
3. Estimated maximum heart rate = 220 – age.
4. Ratio (%) of measured maximum heart rate to estimated maximum heart rate.
The maximum heart rate for each person has been measured during a maximum oxygen uptake test in the laboratory. During the test, the person exercised with increasing intensity until exhaustion, and then the maximum heart rate was measured close to the end of the test. Using this measured maximum heart rate and the estimated maximum heart rate, calculate the percentage of the measured maximum heart rate with respect to the estimated maximum heart rate. Note that this percentage can exceed 100%.
5. Ratio (%) of highest commuting heart rate to measured maximum heart rate. Find the highest maximum commuting heart rate for each person, and then calculate the percentage of this value with respect to the measured maximum heart rate.

OUTPUT: Output should be in the following format and sorted by subject number from low to high:
COMMUTING AND EXERCISE HEART RATE SUMMARY

SUBJECT AVERAGE DAYS ESTIMATED %MEASURED %MAX
NUMBER COMMUTING EXERCISED MAX HR TO COMMUTING
HR ESTIMATED HR TO
MAX HR MEASURED
XXXX XXX.X X XXX XXX.X XXX.X

SAMPLE:
COMMUTING AND EXERCISE HEART RATE SUMMARY

SUBJECT AVERAGE DAYS ESTIMATED %MEASURED %MAX
NUMBER COMMUTING EXERCISED MAX HR TO COMMUTING
HR ESTIMATED HR TO
MAX HR MEASURED
1124 112.5 4 184 96.7 81.5

THEME ISSUES: one-dimensional arrays, nested loops, if statements, file input, file output

How should you do this?
STEP 1 Write main() and open file. Debug.
STEP 2 Write getdata(). At this stage there is a for loop to read each of five days nested inside a while not end of file type loop. Use debug cout statements to check that the data is being input correctly. These must be removed before final submission of project. Debug.
STEP 3 Computations including function as stipulated. Debug.
STEP 4 Write function to output heading. Debug.
STEP 5 Write output function. Debug.
STEP 6 Write function to sort using selection method. Debug.
STEP 7 “Doll up” the program documentation. Debug (just in case)

CIS 22 A

Checkpoint Possible
Include name, e-mail, and lab# as comment and printed to output 3
Minimum of three (3) comments in each function
(Purpose: Pre: Post:) 5
Input function fills all five arrays while calling calculation function. 10
One and only one function must be used to calculate the percentage of measured maximum to estimated heart rate and the percentage of highest commuting heart rate to measure maximum heart rate 5
Use a selection sort to sort subject numbers. This needs to be a separate function. 5
A separate function must be used to output the table heading ONLY 2
Numerical output is done in a separate output function. Output must be formatted as shown. Output correct. Redirect output to a file. 10

HR ESTIMATED HR TO
MAX HR MEASURED
1124 112.5 4 184 96.7 81.5

THEME ISSUES: one-dimensional arrays, nested loops, if statements, file input, file output

How should you do this?
STEP 1 Write main() and open file. Debug.
STEP 2 Write getdata(). At this stage there is a for loop to read each of five days nested inside a while not end of file type loop. Use debug cout statements to check that the data is being input correctly.