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...

``````#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;
}``````

1) What is the problem? Does the compiler produce errors? Does it not work as you would expect? What is your input, expected output, and current erroneous output?

2) I always suggest separating the computation from the user interaction. Hard code some values and get the algorithm working before you get the input from the user. This will help eliminate a source of errors as well as make it quicker for you to debug (you don't have to keep typing in numbers to try it out).

3) Something like this: `const double meter = 0.0254;` should have a much more descriptive name. Maybe "metersPerInch" or something like that.

Good luck,

David

Ty for the fast reply. Im not sure what you mean by nr2. If you could re formulate i would be grateful! well it does not give mé an error but i just wanted another faster and cleaner solution to the assignment based ón the task description. Im writting from iPhone so sry for misspelling. I also wanted to improve and re evalurere My new c++ logic

What I mean is that you should have a function called input() that you can change to either return hard coded values or actually accept input from the user from the keyboard. Then you can carry on testing your code without having to type inputs each time. When you are convinced it is working properly, then you can add back the actual input (cin) commands.

Also, height should be feet*12 + inches instead of just feet*12, right?

The assignment only allows to dó the task under certain rules but thx bro for help. Would be Nice if someone could make an example of how to dó it like a Pro withim