Start New Discussion within our Software Development Community

I am trying to put a 'Invalid' statement in my code and not sure how to do this. Could someone please help me with this? Thank you in advance. Here is my code:

#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
If the input for the gender doesn't match 'F' and doesn't match 'M' complain and exit.
if(gender!='F'&&gender!='M'){
    cout<<"Invalid Gender."<<endl;
    return 0;
}

If the input for the activity doesn't match 'I' and doesn't match 'A' complain and exit.
if(level!='I'&&gender!='A'){
    cout<<"Invalid Activity Level."<<endl;
    return 0;
}
This question has already been answered. Start a new discussion instead.