Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Program A research institute specializing in physiology is conducting a study on the strain and effects ofcommuting trips done on a bicycle or walking.

C++ Program

A research institute specializing in physiology is conducting a study on the strain and effects ofcommuting 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.

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 eachpersons ID number (integer), clinically measured maximum heart rate (integer), and age (integer).The following five lines contain the days average commuting heart rate, maximum commuting heartrate, and exercise heart rate for five consecutive working days. Then, the six line sequence is repeatedfor 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 calculatedvalues as described below.

Look at data for subject 4545 as this is discussed:

4545 190 52114.8 130 113.1102.6 131 0.0117.4 129 149.1-1 -1 114.0114.1 123 119.5 Using this information, calculate1. Average of the average commuting heart rates for each person.

For subject 4545 this would be (114.8 + 102.6 + 117.4 + 114.1)/4 since there was a daythat no reading was available. 2. Number of days that the person exercised on his/her own. For subject 4545 this is 4 since one of the days is 0. 3. Estimated maximum heart rate = 220 age.

For subject 4545 this is 220 52 = 168 4. Ratio (%) of measured maximum heart rate to estimated maximum heart rate.The maximum heart rate for each person has been measured during a maximumoxygen uptake test in the laboratory. During the test, the person exercised withincreasing intensity until exhaustion, and then the maximum heart rate was measuredclose to the end of the test. Using this measured maximum heart rate and the estimatedmaximum heart rate, calculate the percentage of the measured maximum heart ratewith respect to the estimated maximum heart rate. Note that this percentage canexceed 100%. For subject 4545, 190/168 * 100 = 113.1%

5. Ratio (%) of highest commuting heart rate to measured maximum heart rate. Find the highestmaximum commuting heart rate for a person, and then calculate the percentage of this valuewith respect to the measured maximum heart rate.

For subject 4545, 131/ 190 = 69.4%

OUTPUT: Output should be sorted by subject number from low to high with the following:

Subject Number

Average Commuting Heart Rate

Days Exercised

Estimated Max Heart Rate

% Measured to Estimated Max Heart Rate

% Max Commuting to be Measured

Checkpoints:

No two-dimensional arrays, no menu function, and no structures may be used

1. Input function fills all five arrays while calling calculation function for each subject.

2. 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

3. Use a selection sort to sort subject numbers. This needs to be a separate function.

4. A separate function must be used to output the table heading ONLY

5. Numerical output is done in a separate output function. Output must beformatted as shown. Redirect output to a file.

Contents of HR.txt, formatted as on the txt file, my apologies:

6231 181 28 140.1 170 101.8 128.4 156 0.0 145.2 171 106.2 131.3 165 0.0 144.8 170 0.0 1124 178 36 122.8 139 138.4 119.6 142 0.0 117.8 134 133.4 115.3 145 134.2 87.2 109 120.5 7345 195 36 128.4 151 104.6 120.5 153 0.0 134.5 166 140.4 127.4 156 0.0 150.3 169 158.5 9439 197 21 121.5 143 112.2 128.9 145 0.0 126.1 159 134.5 123.0 152 0.0 131.5 147 0.0 4545 190 52 114.8 130 113.1 102.6 131 0.0 117.4 129 149.1 -1 -1 114.0 114.1 123 119.5 2438 200 26 123.0 165 105.4 118.2 130 122.0 121.7 136 124.5 116.1 130 0.0 111.0 152 103.5 2776 178 45 110.3 120 129.1 107.8 132 0.0 111.5 145 135.0 -1 -1 0.0 95.5 119 0.0 8762 186 28 122.7 146 151.9 116.0 137 0.0 119.9 145 0.0 123.3 148 150.0 121.0 142 156.3 4915 185 27 120.3 169 0.0 130.2 150 0.0 123.0 158 0.0 133.4 152 0.0 131.6 159 0.0 3521 181 51 108.3 133 119.3 -1 -1 0.0 117.6 147 125.3 106.7 131 0.0 122.7 159 0.0

Code so far:

#include

#include

#include

using namespace std;

const int MAX = 1000;

void getData(string id[MAX], string hr[MAX], string age[MAX],

int daysEx[MAX], int maxHR[MAX],

double prcM[MAX], double maxComm[MAX]);

int sortArray();

int compute();

int main()

{

string id[MAX];

string hr[MAX];

string age[MAX];

int daysEx[MAX];

int maxHR[MAX];

double prcM[MAX];

double maxComm[MAX];

getData(id, hr, age, daysEx, maxHR, prcM, maxComm);

return 0;

}

void getData(string id[MAX], string hr[MAX], string age[MAX],

int daysEx[MAX], int maxHR[MAX],

double prcM[MAX], double maxComm[MAX])

{

char rand;

ifstream infile;

infile.open("HR.txt");

if(infile.fail())

{

cout << "Cannot find file ";

}

infile >> rand;

for(int i = 0; i < MAX; i++)

{

infile >> id[i];

infile >> hr[i];

infile >> age[i];

infile >> daysEx[i];

infile >> maxHR[i];

infile >> prcM[i];

infile >> maxComm[i];

}

for(int i = 0; i < 2; i++)

{

cout << "SUBJECT NUMBER: " << id[i] << endl;

cout << "AVERAGE COMMUTING HR: " << hr[i] << " ";

cout << "AGE: " << age[i] << endl;

cout << "DAYS EXERCISED: " << daysEx[i] << " ";

cout << "ESTIMATED MAX HR: " << maxHR[i] << " ";

cout << "% MEASURED TO ESTIMATED MAX HR: " << prcM[i] << endl;

cout << "% OF COMMUTING HR TO MEASURED: " << maxComm[i] << endl << endl;

}

}

int sortArray()

{

}

int compute()

{

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Relational Database Technology

Authors: Suad Alagic

1st Edition

354096276X, 978-3540962762

More Books

Students also viewed these Databases questions