calorie counter help please

Pages: 12
only question i have, it has me input a number for Alevel twice when the program is actually running for it to display an output.

IE:

1
2
3
4
5
6
7
8
9
10
11
12
Welcome to Calorie Calculator!!

This program will calculate your caloric Intake!


What is your gender? (1 for female, and 2 for male): 2
how much do you weigh in pounds? 200
What is your activity level?
Select 1 for Low activity, Select 2 for Moderate Activity.
2
2
Your caloric intake is.. 2400.



here is the code surrounding Alevel:
1
2
3
4
5
6
7
8
9
10
	cout << "What is your activity level?\n";
	cout << "Select 1 for Low activity, Select 2 for Moderate Activity."<<endl;
	int Alevel;
	cin>> Alevel;

	while (Alevel != 1 && Alevel != 2)
	{
	cout <<"Not valid, select 1 or 2";
	cin>> Alevel;
	}
No. The second input it not Alevel. Its calories. You never print out "Please enter calories" You simply just let the user do it -

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
while (Alevel != 1 && Alevel != 2)
	{
		cout << "Not valid, select 1 or 2";
		cin >> Alevel;
	}
if (Alevel == 1)
{
           level1_function ();
}
	else
{
           level2_function ();
}
	//get caloric total
}
	int calories;
	cin>> calories;


You see that?

Try adding a cout statement before the calories to make it clearer -

1
2
3
4

        cout << "Please enter the amount of calories "; 
        int calories;
	cin>> calories;
yeah i get that but what i want it to do is just tell the user their caloric intake..

its supposed to go like this:

Ask user for weight

ask user for gender

ask user for activity level


display users total caloric intake based on those other values.
In that case, remove the cin >> calories.

and just leave the int calories;
Topic archived. No new replies allowed.
Pages: 12