Ok, when I run my program it is asking me twice what I only need to be asked once.

#include <iostream>
#include <iomanip>

using namespace std;

int main ()
{
    //Variables
    double calories = 0.0;
    double weight = 0.0;
    char gender = ' ';
    char level = ' ';
    
    
    //enter gender
    cout << "Enter Gender: ";
    cin >> gender;
    gender = toupper (gender);

    
    //calculate
    if (gender == 'F');{
    
               cout << "Enter Your Activity Level (A/I): ";
               cin >> level;
               level = toupper(level);
               
	}
               
               if      (level == 'A');
                       cout << "Enter Current Weight: ";
                       cin >> weight;
                       calories = (weight*12);
                       cout << "You Need This Many Calories Daily To Maintain Your Weight: " << calories << endl;
                       
               
               
               else    (level == 'I');
                       cout << "Enter Current Weight:  ";
                       cin >> weight;
                       calories = (weight*10);
                       cout << "You Need This Many Calories Daily To Maintain Your Weight: " << calories << endl;
                       
   
    
    

    else (gender == 'M');  {         
   
               cout << "Enter Your Activity Level (A/I): ";
               cin >> level;
               level = toupper(level);
	}
               
               if       (level == 'A');{
                        cout << "Enter Current Weight: ";
                        cin >> weight;
                        calories = (weight*15);
                        cout << "You Need This Many Calories Daily To Maintain Your Weight: " << calories <<endl;
                        }
               
               
               else     (level == 'I');{
                        cout << "Enter Current Weight:  ";
                        cin >> weight;
                        calories = (weight*13);
                        cout << "You Need This Many Calories Daily To Maintain Your Weight:  " << calories <<endl;
                        }
     

               
// display output
               
system ("pause");
return 0;

} //end main function

Would someone please guide me in the right direction. Thank you in advance. :)

Edited 4 Years Ago by dlmagers: n/a

Attachments Capture.JPG 41.59 KB

I can't tell you why you have to give twice a answer, but you can correct your code.
After the conditions you write a semicolon what makes the condition end here.
Your braces are wrong placed.
I suggest a gender should contain the case a and i, but they are out of the scope of a gender-condition.
If you are new to C++ go read more about scopes and conditions.

Edited 4 Years Ago by Dman01: n/a

When you get to this section of the program that executes:

//enter gender
    cout << "Enter Gender: ";
    cin >> gender;
    gender = toupper (gender);

how many and what keys are pressed?
Are all the keys read by the program? Why or why not?

This article has been dead for over six months. Start a new discussion instead.