Computing.Net > Forums > Programming > Please check my C++ programming!!!

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Please check my C++ programming!!!

Reply to Message Icon

Name: kenvu90
Date: February 15, 2009 at 19:59:53 Pacific
OS: Windows Vista
Subcategory: C/C++
Comment:

// 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;
}



Sponsored Link
Ads by Google

Response Number 1
Name: klint
Date: February 16, 2009 at 03:10:41 Pacific
Reply:

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.


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Please check my C++ programming!!!

how to run my C++ program in bakgrn www.computing.net/answers/programming/how-to-run-my-c-program-in-bakgrn/12618.html

Help with my C++ program www.computing.net/answers/programming/help-with-my-c-program/1813.html

stacktrace in C program on Solaris8 www.computing.net/answers/programming/stacktrace-in-c-program-on-solaris8/15177.html