New at C++ And need help

I need help with a problem I have the majority of the code written, but I am running into some problems getting it to work properly.

The problem is as follows;

Write a program to compute the ideal weight for both males and females. According to one study, the ideal weight for a female is 100 pounds plus 5 pounds for each inch in height over 5 feet. For example, the ideal weight for a female who is 5'3" would be 100 + 3*5= 115 pounds. For a male the ideal weight is 106 pounds plus 6 pounds for each inch in height over 5 feet. For example, the ideal weight for a male who is 5'3" would be 106 + 3*6 = 124 pounds. Your program should ask the user to enter his/her height in feet and inches (both as integers — so a person 5'3" would enter the 5 and the 3). It should then compute and print both the ideal weight for a female and the ideal weight for a male.

So I have the following
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

#include <iostream>
using namespace std;
int main()
{
int feet, inches, mweight, fweight;
feet =;
inches =;
mweight = 106 + inches*6;
fweight = 100 + inches*5;

cout << "Enter your height in feet and inches:";
cin >> feet; cin >> inches;
cout << "If you are male, your ideal weight should be" << mweight << "pounds." << endl;
cout << "If you are female, your ideal weight should be" << fweight << "pounds." << endl;
system("pause");
return 0;
}

The reality of feet is invalid because the assumption is everyone is 5 foot tall for this project. So for the format you only need to factor in the amount of inches into the process. So if the person is 5'10 they will only need to worry about the 10 inches. 106+ 10*5.

Any assistance is appreciated, and if you can explain what I did wrong, I would be thankful.
this is not an environment variable where you can write int feet=; you must put a value.
Put 0 for all of them first.

then call the two cin to set new values

then calculate male weight , female weight

then print the values.

also you dont have used the variable feet , is it intended ?
The assignment statements at lines 9 and 10 don't behave like a spreadsheet where an update to "inches" would cause an automatic update to mweight and fweight. Instead, the value is computed and assigned when the statement executes. So you need to move lines 9 & 10 after line 13.

But as you've already the formula should work for number of inches OVER 5 ft. My advice is to create a separate variable to hold this difference and then use it in the formula:
1
2
3
int over5ft = (12*ft + inches) - 5*12;
mweight = 106 + over5ft * 6;
fweight - 100 + over5ft * 5;

The value of feet is technically not important because under the problem the assumption is if you are over 5 feet you use 100 for female and 106 for male for the calculation.

So it would be
feet = 0;
Inches = 0;

Do I need any float or double prefixes?

And should I use any if otherwise statements?





With your assistance, it works properly. Thank you all very much for your assistance.
Topic archived. No new replies allowed.