Entry Form Validation

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.
How would I combine the first and last name strings into one string?
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
#include <iostream>

int main()
{
    std::cout << "Please enter name: ";
    std::string userName;
    std::getline(std::cin, userName);   // this will read an entire line, 
                                        // spaces included

    std::cout << "Enter age of " << userName << ": ";
    int Age = 0;
    std::cin >> Age;

    std::cout << "Enter gender of " << userName << ": ";
    int Gender = 0;
    std::cin >> Gender;

    std::cout << "Enter hours: ";
    int timeHours = 0;
    std::cin >> timeHours;

    std::cout << "Enter minutes: ";
    int timeMin = 0;
    std::cin >> timeMin;

    std::cout << "Enter seconds: ";
    int timeSec = 0;
    std::cin >> timeSec;
    return 0;
}

Thank you
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?
One way to do it
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
  const int MALE = 1;
  const int 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
  }  
Topic archived. No new replies allowed.