Unable to run this program, please help

//Gina AdamsSpiller
//CSCI 1010
//This program will caculate BMI
#include<iostream>
#include<string>
using namespace std;
int main()
//Display message;
{
int height = 0;
int weight = 0;
int BMI = 0;

cout << "Welcome to Gina Programmer's BMI calculator" << endl;
//Prompt for weight in pound;
cout << "enter the subject's weight in pounds:"<<endl;
cin >> weight;
//Prompt for height in feet and inches;
cout << "enter the subject's height (feet and inches)"<<endl;
cin >> height;
//Prompt for first name;
cout << "Enter first name" << endl;
cout << "Pat"<<endl;
//calculate height in inches by (feet*12*inches);
double TotalHeight;
TotalHeight = (feet * 12) + inches;
//add weight*703
double adjusted;
weight = weight * 703
//Caculate square of height;
Double HeightSq = (totalHeight*totalHeight);
//Calculate BMI;
double BMI = (adjusted_weight / HeightSq);
//Display name and BMI
cout << "Pat" "has a BI of:"; BMI <<
//Display table
cout << "[Table here]" << endl<< endl;
cout << "Thank you for using Gina's BMI calculator" << endl;
system("PAUSE");
return 0;
}
cl /EHsc /W4 /Ox /std:c++17 a.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 19.21.27702.2 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.

a.cpp
a.cpp(26): error C2065: 'feet': undeclared identifier
a.cpp(26): error C2065: 'inches': undeclared identifier
a.cpp(31): error C2146: syntax error: missing ';' before identifier 'Double'
a.cpp(31): error C2065: 'Double': undeclared identifier
a.cpp(31): error C2146: syntax error: missing ';' before identifier 'HeightSq'
a.cpp(31): error C2065: 'HeightSq': undeclared identifier
a.cpp(31): error C2065: 'totalHeight': undeclared identifier
a.cpp(31): error C2065: 'totalHeight': undeclared identifier
a.cpp(33): error C2371: 'BMI': redefinition; different basic types
a.cpp(12): note: see declaration of 'BMI'
a.cpp(33): error C2065: 'adjusted_weight': undeclared identifier
a.cpp(33): error C2065: 'HeightSq': undeclared identifier
a.cpp(35): error C2088: '<<': illegal for class
a.cpp(37): error C2297: '<<': illegal, right operand has type 'const char [13]'
a.cpp(37): error C2563: mismatch in formal parameter list
a.cpp(37): error C2568: '<<': unable to resolve function overload
a.cpp(37): note: could be 'std::basic_ostream<_Elem,_Traits> &std::endl(std::basic_ostream<_Elem,_Traits> &)'

Computers are really, really, strictly stupid. For example, "Double" is not the same as "double". Hence the error.

Likewise, "feet" and "inches" were never declared with something like int feet; or double feet;.

Line 33 is trying to declare another variable named "BMI" with a different type (double instead of int). The first is already declared on line 12. Pick one. (Remove the other.)

Remember, it is okay to declare a variable in one spot and simply assign to it in another spot.

1
2
3
double BMI;
...
BMI = adjusted_weight / HeightSq;

You should, however, get into the habit of keeping declaration and assignment as close together as possible. In this case, you could just get rid of the declaration at the top and do everything on line 33:

 
double BMI = adjusted_weight / HeightSq;


The remaining errors (illegal << stuff) start with a syntax error on line 35, where you started writing an output statement and didn't finish.

Remember to use your compiler's error messages to help you figure out what you typed wrong. Those of us who have been doing this for ages are very good at looking at those messages and fixing our typos and brain farts.

Hope this helps.
Hello Gspiller81,

The only things I can add to what Duthomhas has started with is:

PLEASE ALWAYS USE CODE TAGS (the <> formatting button), to the right of this box, when posting code.

Along with the proper indenting it makes it easier to read your code and also easier to respond to your post.

http://www.cplusplus.com/articles/jEywvCM9/
http://www.cplusplus.com/articles/z13hAqkS/

Hint: You can edit your post, highlight your code and press the <> formatting button.

You can use the preview button at the bottom to see how it looks.

I found the second link to be the most help.



When writing your code compile often and fix your mistakes as you go and not all at one time when you are finished.

Andy
Topic archived. No new replies allowed.