I am trying to write a code to determine the eligibility of entrants into a marathon. My parameters are to enter a name, enter the age of said name, enter the gender, and then to enter the time separately in int value in hours, minutes and seconds. Here is what I have so far. For some reason, I'm not being allowed to input the age or anything like that. What am I doing wrong?
string userFirstName;
string userLastName;
int Age;
int Gender;
int timeHours;
int timeMin;
int timeSec;
cout << "Please enter a name:" << endl;
cin >> userFirstName,userLastName;
cout << "Enter age of " << userFirstName << ":" <<endl;
this is where I'm not being allowed to enter the age into the program.
cin >> userFirstName,userLastName;
You better input each value separately.
1 2 3 4 5 6 7
cout << "\nPlease enter first name: ";
cin >> userFirstName;
cout << "\nPlease enter last name: ";
cin >> userLastName;
cout << "\nEnter age of " << userFirstName << ": ";
cin >> Age;
// and so on
Thank you for the reply. That was the order in which I was going, but when I compile and build it, it won't let me input the Age or anything else for that matter. I am only able to input the name.
My program is running well thus far. However, I am now having trouble with using Boolean comparisons to determine if a candidate is eligible. How would you write out or assign 1 or 2 as being a male or female when it comes to gender? How would I nest a statement that would say if a male is under the age of 18, he would not qualify?
constint MALE = 1;
constint FEMALE = 2;
std::cout << "Enter gender of " << userName << "(1 = male, 2 = female): ";
int Gender = 0;
std::cin >> Gender;
// normally you should check that Gender is only 1 or 2 but it might not be required
if (Gender == MALE && Age < 18)
{
// some not allowed message
}
else
{
// get the rest og the input
}