-A simple rule to estimate your ideal body weight is to allow 110 pounds for the
ID: 3561803 • Letter: #
Question
-A simple rule to estimate your ideal body weight is to allow 110 pounds for the first 5 feet of height and 5 pounds for each additional inch. Write a program with a variable for the height of a person in feet and another variable for the additional inches and input values for these variables from the keyboard. Assume the person is at least 5 feet tall. For example, a person that is 6 feet and 3 inches tall would be represented with a variable that stores the number 6 and another variable that stores the number 3. Based on these values calculate and output the ideal body weight.
-Your program should ask the user for their height in two steps: First ask for the number of feet, then ask for the number of inches. Your program should then display the ideal weight for that height
This is what I have so far. I need to run this in Linux but I'm getting some errors. please Help:
#include <iostream>
using namespace std;
int main()
{
int height_feet;
int height_in;
int conv_1;
int conv_2;
// 110 first 5 ft
// 5 for each addition inch.
cout << "What is your height rounded off in feet?" << endl;
cin >> height_feet;
cout << "What is the rest of your height in inches?" << endl;
cin >> height_in;
if (height_feet >= 5) {
conv_1 = 110 + (height_in * 5);
cout << "You weigh " << conv_1 << " in lbs." << endl;
} else {
cout << "You must weigh less than 110 lbs." << endl;
}
return 0;
}
Explanation / Answer
#include <iostream>
using namespace std;
int main()
{
int height_feet;
int height_in;
int conv_1;
int conv_2;
// 110 first 5 ft
// 5 for each addition inch.
cout << "What is your height rounded off in feet?" << endl;
cin >> height_feet;
cout << "What is the rest of your height in inches?" << endl;
cin >> height_in;
if (height_feet >= 5) {
conv_1 = 110 + ((height_feet-5)*60)+(height_in * 5);
cout << "You weight " << conv_1 << " in lbs." << endl;
} else {
cout << "You must weight less than 110 lbs." << endl;
}
return 0;
}
Here is your Program
Now it is absolutely correct
I have added one term that is in bold font check it out.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.