2 getlines in if statement

First let me start by saying I'm new to the world of programing, and finishing up my first semester of class on this subject so please bare with me. And I apologize if I ask what seems to be a stupid question, I just want to learn as much as I can, and want to understand everything that I can.

Okay, problem at hand. this is an assignment for class, were I have to create a program that takes reservations, and has a menu system and user selects the options. The part I'm stuck on is creating the reservation, the user will input the customer name, phone number then the program will generate a seat number and price. However first it must scan the boat, array, to make sure their is an empty seat, and if so then it gets the info.

So the problem I have is that when I go to run the if statement, assuming it finds empty seat, will then display, enter customer name, then getline function and input that into a array, and I'm using getline because names can have first and last, and thus the space. then after getting the name it should go to the phone number, and do the same, but the problem is that when it runs, it displays enter name, enter phone number at the same time, and I need them 1 at a time. Bellow is my code, Thanks so much for any and all assistance, I just can't seem to find were I am going wrong on this.

void MakeNewReservation(string name[], string phone[])
{
string customerinfo;
string phonenumber;
//int SeatNumber[10] = {1,2,3,4,5,6,7,8,9,10};
int SeatNumber;
fstream Price, Reservations;
float price;
int EmptySeats, index;

for (int index=0; index<10; index++)
{
if (name[index]=="x")
{
cout<< "Enter Customer Name: "<<std::endl;
name[index]=customerinfo;
getline(cin,customerinfo);

cout<<endl;

cout<< "Enter Phone Numebr and press enter: "<<std::endl;
phone[index]=phonenumber;
getline (cin, phonenumber);


//generate seat number
SeatNumber=index+1;
cout<<"Seat Number is = "<<SeatNumber<<endl;
break;
} // end of if statement

else
{
cout<< "Boat is full"<<endl;
}//end of else statement

} //end of for statement

//count number of empty seats
for (index=0; index<10; index++)
{
EmptySeats=0;
if (name[index]=="x")
{
EmptySeats=EmptySeats + 1;
}
}

//pull info, boat name and price from Price.txt

//write info to Reservations.txt
Reservations<<name << '\t' << SeatNumber<<endl; //add price before seat number
}
Topic archived. No new replies allowed.