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. :)

Recommended Answers

All 2 Replies

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.

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?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.