Skipping cin statements

I am new to C++ and don't know too much yet. I need an input for every cin statement. I am only able to choose a gender. After that, it prints the rest cout statements on the same line, ignoring every cin.
(The extra ints' are for later, I know they are unused right now)

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
  #include <iomanip>
#include <iostream>

using namespace std;

int main()
{
    /*This block defines all the variables and allows the user to put in their information*/
    int Age, Weight, Height, Gender, BMRm, BMRw, Cookies;
    const int cookCal = 210;

    cout << "Please provide your basic information" << endl;

    cout << "male or female (m or f)? ";
    cin >> Gender;

    cout << "age in years? ";
    cin >> Age;
        
    cout << "weight in kg? ";
    cin >> Weight;

    cout << "height in cm? ";
    cin >> Height;

    BMRm = 88.362 + ( 13.397 * Weight ) + ( 4.799 * Height ) - ( 5.677 * Age );

    BMRw = 447.593 + ( 9.247 * Weight ) + ( 3.098 * Height) - (4.330 * Age );

    return 0;
}
Last edited on
You set "Gender" to accept input 'm' or 'f' which are char. Make Gender a char, not an int.
I changed gender to a char because an Int is a whole number. a char is a character (like on your keyboard) and that can accept M or F. Int also isn't really a good thing for something like this since your result has decimals and int rounds, and also an int can't use a very high number, so I changed the Ints to Doubles. Let me know what you think of this, and if you need help with anything else in this program I would be glad to try!

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
#include <iomanip>
#include <iostream>

using namespace std;

int main()
{
    /*This block defines all the variables and allows the user to put in their information*/
    double Age, Weight, Height, BMRm, BMRw, Cookies;
    char gender;
    const int cookCal = 210;

    cout << "Please provide your basic information" << endl;

    cout << "male or female (m or f)? ";
    cin >> gender;

    cout << "age in years? ";
    cin >> Age;

    cout << "weight in kg? ";
    cin >> Weight;

    cout << "height in cm? ";
    cin >> Height;

    BMRm = 88.362 + ( 13.397 * Weight ) + ( 4.799 * Height ) - ( 5.677 * Age );

    BMRw = 447.593 + ( 9.247 * Weight ) + ( 3.098 * Height) - (4.330 * Age );

    return 0;
}
Last edited on
Topic archived. No new replies allowed.