I need someone check my program!!

February 12, 2009 at 16:18:02
Specs: Windows Vista
I need a documentation on(not long):
1. Problem analysis (input, outputs, formulas, assumptions)
2. Algorithm

Below is the the question and my response...!!!

I'm creating program to help a small fitness center produce baseline information for new customers. The program inputs four pieces of data:

1) Customer’s first name (string)
2) Customer’s age (integer)
3) Customer’s height in inches (integer) (e.g., 65 if customer is 5’, 5” tall)
4) Customer’s weight (float)

The program must produce the following outputs:

1) Customer’s first name as entered (string)
2) Customer’s age as entered (integer)
3) Customer’s height in feet and inches (e.g., 5’ 5” if customer is 65 inches tall) (both integer)
4) Customer’s calculated BMI (Body Mass Index) (float)
5) Customer’s starting target heart rate – 65% of max (float)
6) Customer’s final target heart rate – 85% of max (float)

Processing:

1) Convert the customer’s height in inches to height in feet and inches
2) Calculate the customer’s maximum heart rate (using the formula “220 – age”)
3) Calculate the starting target heart rate (65% of the maximum heart rate)
4) Calculate the final target heart rate (85% of the maximum heart rate)
5) Calculate the body mass index using the formula:

BMI = ( Weight in Pounds / ( Height in inches ) x ( Height in inches ) ) x 703

6) Output all specified values with appropriate labels

// produce baseline information for new customers

#include <cmath> // sqrt function
#include <iostream> // i/o function
#iclude <string>
using namespace std;

int main()
{
string firstName; // input and output: first name
int age; // input and output: age
int inches; // input: height in inches
int feet; // output: height in feet and inches
float weight; // input: weight
float BMI; // output: calculationd BMI
float starting_THR; // output: starting target heart rate - 65% of max
float final_THR; // output: final target heart rate - 85% of max
// Read in custumer's firts name.
cout << "Enter your first name: " << endl;
cin >> firstName;

// Read in customer's age.
cout << "Enter your age: " << endl;
cin >> age;

// Read in customer's weight.
cout << "Enter your weight: " << endl;
cin >> weight;

// Get the height in inches to height in feet and inches.
cout << "Enter inches: " << endl;
cin >> inches;
cout << "Enter feets: " << endl;
cin >> feet;

// Convert inches to feet and inches.
feet = inches / 12;
inches = inches % 12;

//Display the height in inches to height in feet and inches.


// Compute maximum heart rate.
MHR = 220 - age;

// Compute the starting target heart rate.
starting_THR = 0.65 * MHR;

// Calculate the final target heart rate.
final_THR = 0.85 * MHR;

// Compute the body mass index.
BMI = (weightInLbs/(heightInInches) * (heightInInches)) * 703;

// Display the body mass index.
cout << "BMI is: " << endl;

return 0;
}


See More: I need someone check my program!!

Report •


#1
February 12, 2009 at 17:41:11
Input:
3) Customer’s height in inches (integer) (e.g., 65 if customer is 5’, 5” tall)
4) Customer’s weight (float)

You swap the order of these. I'm not sure how hard up your professor is about such things.
Also, you should only ask for the height in inches, not feet and inches.

Output:
1) Customer’s first name as entered (string)
2) Customer’s age as entered (integer)
3) Customer’s height in feet and inches (e.g., 5’ 5” if customer is 65 inches tall) (both integer)
4) Customer’s calculated BMI (Body Mass Index) (float)
5) Customer’s starting target heart rate – 65% of max (float)
6) Customer’s final target heart rate – 85% of max (float)

Missing. (You almost show the BMI, but not quite.)

Code:
#include <cmath> // sqrt function
You never use sqrt() (nor anything else in cmath).

// Convert inches to feet and inches.
feet = inches / 12;
inches = inches % 12;

It's better to keep track of only the inches, and convert this to feet and inches on demand.

BMI = (weightInLbs/(heightInInches) * (heightInInches)) * 703;
You never declare weightInLbs nor heightInInches.


Report •

#2
February 12, 2009 at 18:43:12
So basicly you said that the problem analysis is: what you just reply, right?

Report •

Related Solutions


Ask Question