bmi calculator, i need some help

Im trying to make a BMI calculator and cannot figure out where I went wrong. It runs and compiles without any errors but doesn't give me at all the output i need.
heres the code..im really new to c++, any help would be great


#include <iostream>

using namespace std;


int main()
{
double feet;
double inches;
double height;
double weight;
double bmi;

bmi= (weight*703) / (height * height);
height = (feet * 12) + inches;



cout<<"== BMI Calculator =="<<endl;
cout<<"Step 1: Enter height"<<endl;
cout<<"Feet:"<<endl;
cin>>feet;
cout<<"Inches:"<<endl;
cin>>inches;
cout<<"step 2: Enter weight"<<endl;
cout<<"Pounds:"<<endl;
cin>>weight;
cout<<"BMI: "<<bmi<<endl;
}
You are defining your formulas before actually putting in some value. So when the program is running, it reads what the bmi and height should be, but guess what? You haven't told the program what weight, height and inches are yet.
how exactly would i go about fixing this?
When your program is running, it reads from the top till it gets to the end of the program per say.
It will read bmi first and try to calculate it, but since you don't have numbers in weight and height yet, it will calculate with something and spit out a garbage output. So what you do is put the formulas after the user inputs the numbers but before each one is called. So put height after you get the number of feet and inches; put bmi after you get the number for weight and height but before you output its value, soo something like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <iostream>

using namespace std;


int main()
{
double feet;
double inches;
double height;
double weight;
double bmi;

cout<<"== BMI Calculator =="<<endl;
cout<<"Step 1: Enter height"<<endl;

cout<<"Feet:"<<endl;
cin>>feet;

cout<<"Inches:"<<endl;
cin>>inches;

cout<<"step 2: Enter weight"<<endl;
cout<<"Pounds:"<<endl;
cin>>weight;

height = (feet * 12) + inches;
bmi= (weight*703) / (height * height);

cout<<"BMI: "<<bmi<<endl;

}

Should work if you follow that. 
Topic archived. No new replies allowed.