Hello this problem is from the beginner book C++ Primer Plus 5th edition..
The problem sounds something like this: Write a short program that asks for your height in feet and inches and your weight in pounds(Use three variables to store the information).
Have the program report your body mass index(BMI). To calculate BMI, first convert your height in feet and inches to your height in inches(1 foot = 12 inches).
Then convert your height in inches to your height in meters by multiplying by 0.0254.
Then convert your weight in pounds into your mass in kilograms by the quare of your height in meters. Use symbolic constants to represent the various conversion factore...
ok now for the program I wrote.. Where did I go wrong, please help.
#include <iostream> //I know its suppose to be a short program... I hope you can help me with that too
using namespace std; //The uses of many couts is just to make it easier for myself to identify the code since im a noob
int main (){
//3 variables
int inches, lbs, feet;
//height in feet and inches
cout << "Enter your height in feet and inches: ";
cin >> feet >> inches;
//weight in pounds
cout << "Enter your weight in pounds: ";
cin >> lbs;
//the symbolic constants mention I think...
const double meter = 0.0254;
const double kilo = 2.2;
//My new final height
int height = feet*12;
cout << "Converted height: " << height <<endl;
double heightInMeters = height * meter;
cout << "Final Height: "<< heightInMeters<<endl;
//Finally my BMI
double kilomass = lbs / kilo;
cout << "Your kilomass is: "<< kilomass<<endl;
double bmi = kilomass / (heightInMeters * heightInMeters);
cout << "Your Bmi is: "<<bmi;
cin.get();
cin.get();
return 0;
}