I am working on creating a program in C++ Visual Studio 2010 express ,below are he requirements. I am coming up with an error and I am unsure on how to fix it.I also am confused about what a meaningful comment is...
Create a program that calculates a persons Body Mass Index (BMI).
You will need the persons height in inches and their weight in pounds.
The formula to calculate the Body Mass Index is:
BMI = ( W * 703 ) / ( H * H )
Where: BMI = Body Mass Index
W = weight in pounds
H = height in inches
In addition to correctly calculating the numeric value of the BMI, your program should also display the descriptive word that corresponds to the following range of BMI values:
Range of BMI Values
Description
Less than 18.5
Underweight
18.5 or greater, but less than 25
Normal
25 or greater, but less than 30
Overweight
30 or greater
Obese
Your program should do the following:
1. Prompt the user for their weight in pounds.
2. Prompt the user for their height in inches.
3. Echo the weight and height values back to the User.
3. Calculate and display the BMI value.
4. Display the descriptive word that corresponds to their BMI value.
You must:
Interact effectively with the user.
Document the program with meaningful comments.
** Include your name as the programmer in a comment near the top of the file that contains the program’s entry point. If you do not know what your program’s entry point is, look it up. You are here to learn.
Use variable names that have meaning. Do not use BROLE, SNEET, GWORP, orZANTZ as variable names. Use variable names that communicate their meaning even if they are more than six characters in length. Use a variable name liketotalPoints or total_points rather than a variable name like totpts.
Include comments in your program. Some programmers write the comments first as a form of pseudo code. Then as a second step, they compose the programming statements that will do what each comment describes***
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
|
// projone.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include<iostream>
using namespace std;
int main()
{
double weight;
double height;
cout <<"Enter your weight in pounds :";
cin >> weight;
cout << endl;
cout <<"Enter your height in inches :";
cin >> height;
cout << endl;
cout <<"Weight is given by " << weight << endl;
cout <<"Height is given by " << height << endl;
double bmi = ( weight * 703 ) / ( height * height );
cout <<"BMI given by " << bmi << endl;
if(bmi < 18.5)
cout << " Underweight " << endl;
else if(bmi >= 18.5 && bmi < 25)
cout << " Normal " << endl;
else if(bmi >= 25 && bmi < 30)
cout << " Overweight " << endl;
else if(bmi >=30)
cout << " Obese " << endl;
return 0;
}
{
return 0;
}
|
ERROR: 1>------ Build started: Project: projone, Configuration: Debug Win32 ------
1> projone.cpp
1>c:\users\copper\documents\school\programming\projects\projone\projone\projone.cpp(34): error C2447: '{' : missing function header (old-style formal list?)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========