Please check my C++ programming!!!

February 15, 2009 at 19:59:53
Specs: Windows Vista
// 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 MHR; // maximum heart rate
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 = (weight in pounds /(height in inches) * (height in inches)) * 703;

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

return 0;

See More: Please check my C++ programming!!!

Report •

February 16, 2009 at 03:10:41
The code is very simple, you can answer it yourself. First, you need to understand exactly what you are trying to do. The code makes it look as if you are a bit confused. Are you trying to ask for the user's height in feet and inches? Then why ask for inches first, followed by feet? And why are you inputting feet, and then immediately throwing away the answer and re-calculating it from inches? You need to look at your code carefully, and understand exactly what your code is doing, and make it match your understanding of exactly what you are trying to achieve.

Report •
Related Solutions

Ask Question