Invalid input statement
I am trying to figure out where I would put a 'Invalid input' statement. Would I put it in a 'default' statement?
My code it this:
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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
#include <iostream>
#include <iostream>
#include <cctype> // is needed for toupper()
#include <cstdlib> // is needed for system()
using std :: cout;
using std :: cin;
using std :: endl;
using std :: toupper;
using std :: system;
int main ()
{
//Variables
double calories = 0.0;
double weight = 0.0;
int weight_mod = 0;
char gender = ' ';
char level = ' ';
//enter gender
cout << "Enter Gender: ";
cin >> gender;
gender = toupper(gender);
cout << "Enter Your Activity Level (A/I): ";
cin >> level;
level = toupper(level);
cout << "Enter Current Weight: ";
cin >> weight;
if (gender == 'F' && level == 'A')
{
weight_mod = 12;
}
else if (gender == 'F' && level == 'I')
{
weight_mod = 10;
}
else if (gender == 'M' && level == 'A')
{
weight_mod = 15;
}
else if (gender == 'M' && level == 'I')
{
weight_mod = 13;
}
// calculate
calories = weight * weight_mod;
// display output
cout << "You need this many calories daily to maintain your weight: " << calories << endl;
system ("pause");
return 0;
} //end main function
|
Please help! Thank you in advance.
http://cplusplus.com/doc/tutorial/control/
Topic archived. No new replies allowed.