I got one version of C++ program that hotel booking or check in whatever you call. see the program below.
Now I want to modify this program with "Struct" and array for room number and customer name. Any other function should be working as original program above.
I post one more function for this program separately.please see
Please help me out
cout<<"\n\nPlease enter customer name you which to search: ";
cin>>finding;
//for(int i=1;i<=NUMBER_OF_ROOMS;i++)
while (found==false)
{
if (ser[i]==finding)
{
cout<<"\n\t"<<ser[i]<<" staying in room no. "<<i+1<<"\n\n";
found=true;
}
else
i++;
if (i>NUMBER_OF_ROOMS)
{
cout<<"\n\tCan't fine the customer!! "<<endl;
cout<<"\n\tDo you want to serach again? (y/n)";
cin>>y_n;
if (y_n=='y'){
i=0;
cout<<"\n\nPlease enter customer name you which to search: ";
cin>>finding;
}
else if (y_n=='n')
found= true;
}
}
to_Menu();
}
void makeBookings(string hotel[])
{
int roomNumber = 0;
string occupant = " ";
int check=0;
int roomIndex=0;
bool loop_end=true;
for (int i = 0; i < NUMBER_OF_ROOMS; i++)
{
if (hotel[i] == EMPTY_ROOM)
{
cout<<setw(9)<<"|";
cout<<setw(3)<<i+1;
cout<<setw(4)<<"|";
cout<<setw(15)<<"|";
cout<<setw(10)<<EMPTY_ROOM;
cout<<setw(4)<<"|"<<endl;
check++;
}
}
if (check==0){
cout<<"\n\tSORRY! ALL THE ROOM ARE FULL"<<endl;
cout<<"\tCANNOT BE BOOK"<<endl;
}else{
cout << "\tPlease follow the instruction below "<<endl;
do{
cout << "\n\n\tPlease enter a room number: ";
cin >> roomNumber;
int roomIndex=roomNumber - 1; //convert real room to an index
if (roomNumber>NUMBER_OF_ROOMS || roomNumber<1)
{
cout<<"\n\tInvalid room number!!\n"<<endl;
}else if (hotel[roomIndex] != EMPTY_ROOM){
cout << "\n\tSorry this room is occupied by "<<hotel[roomIndex]<<endl;
cout << "\tPlease chose another room"<<endl;
}
else{
cout << "\n\tEnter the name of the main occupant: ";
//getline(cin,occupant);
cin>>occupant;
hotel[roomIndex] = occupant;
background_Save(hotel);
loop_end = false;
}
}while (loop_end == true);
}
to_Menu();
}
void displayHotel(string h[])
{
int check=0;
cout<<"\t== HOTEL EMPTY ROOMS =="<<endl;
cout<<"\n";
cout<<setw(16)<<"Room No."<<setw(29)<<"Customer's Name"<<endl;
for (int i = 0; i < NUMBER_OF_ROOMS; i++)
{
if (h[i] == EMPTY_ROOM)
{
cout<<setw(9)<<"|";
cout<<setw(3)<<i+1;
cout<<setw(4)<<"|";
cout<<setw(15)<<"|";
cout<<setw(10)<<EMPTY_ROOM;
cout<<setw(4)<<"|"<<endl;
check++;
}
}
if(check==0)
cout<<"\n\tSORRY !! THIS HOTEL IS FULL AT THE MOMENT "<<endl;
to_Menu();
}
cout<<"\t== Customer Leaving from room =="<<endl;
cout<<"\n";
cout<<setw(16)<<"Room No."<<setw(29)<<"Customer's Name"<<endl;
for(int i=0;i<NUMBER_OF_ROOMS;i++)
{
cout<<setw(9)<<"|";
cout<<setw(3)<<i+1;
cout<<setw(4)<<"|";
cout<<setw(15)<<"|";
cout<<setw(10)<<h[i];
cout<<setw(4)<<"|"<<endl;
}
while(pass_Room==false)
{
cout<<"\n\tPlease select the room number: ";
cin>> room_num;
if (room_num>NUMBER_OF_ROOMS || room_num<1)
cout<<"\n\t!! Invalid room number"<<endl<<"\n\tPlease select the room number again "<<endl;
else pass_Room= true ;
}
cout<<"\tAre you sure to delete customer from the room!!"<<endl;
while(y_n!='N')
{
cout<< "\tY/N? ";
cin>>Y_N;
y_n=return_first_char(Y_N);
y_n=toupper(y_n);
switch(y_n){
case 'Y':
room_num = room_num - 1;
if (h[room_num]=="empty")
cout<<"\tNo one in the room no. "<<room_num+1<<"\n\n"<<endl;
else
{
h[room_num]="empty";
cout<<"\tRoom no. "<<room_num+1<<" is empty now\n\n"<<endl;
}
background_Save(h);
y_n='N';
break;
case 'N':
y_n='N';
break;
default: cout<<"\n\tInvalid choice! ";
}
}
to_Menu();
}
void menu_Diaplay()
{
cout<<"\n\n";
cout<<"\t== Main Menu =="<<endl;
cout<<"\n\n";
cout<<"\tPress A:\tAdd Customer to room"<<endl;
cout<<"\tPress V:\tView All Room"<<endl;
cout<<"\tPress E:\tDisplay Empty rooms"<<endl;
cout<<"\tPress D:\tDelete customer from room"<<endl;
cout<<"\tPress F:\tFind room from customer name"<<endl;
cout<<"\tPress S:\tSave program data in to file"<<endl;
cout<<"\tPress L:\tLoad program data from file"<<endl;
cout<<"\tPress O:\tView rooms Ordered alphabetically by name"<<endl;
cout<<"\tPress Q:\tTo Quit"<<endl;
cout<<""<<endl;