Question: C++ Programming, this is the coding for my Final project, as it is too small, I want you to add more functions and arrays or
C++ Programming, this is the coding for my Final project, as it is too small,
I want you to add more functions and arrays or etc to make the code lenghty.
Topic is about: hotel management system (Booking Rooms)
Thanks
#include #include #include using namespace std; struct System { string name; string phone; int room; } ; int roomnum; int Menu (); string bookRoom (int&); void custRecord (System[]); void roomStatus (System[]); void editRecord (System*); void file (System[]); int main() { int x; char key; System hotel[50]; cout<<" ********************"< cout<<" WELCOME TO HOTEL ABC"< cout<<" ********************"< x=Menu(); while (x!=0) { if (x==1) { string type = bookRoom(roomnum); while (hotel[roomnum].room==1) { cout<<"Sorry this room is already booked. Try another room."; cout<>roomnum; } hotel[roomnum].room=1; cout<<"Enter name : "; cin>>hotel[roomnum].name; cout<<"Enter phone number : "; cin>>hotel[roomnum].phone; cout< } else if (x==2) custRecord (hotel); else if (x==3) roomStatus(hotel); else if (x==4) editRecord(hotel); else cout< cout<<"Enter choice (press 0 to exit) : "; cin>>x; } cout<<"Do you want to save the data before quitting? (press Y for yes) : "; cin>>key; if (key=='y' || key=='Y') file(hotel); else cout<<"Data is not saved. Thank you."; return 0; } int Menu () { int choice; cout<<" MENU"< cout<<" 1. Book a room"< cout<<" 2. Customer record"< cout<<" 3. Room"< cout<<" 4. Edit record"< cout<>choice; return choice; } string bookRoom (int& roomnum) { string type; cout< cout<<" 1. Single Room 1-14"< cout<<" 2. Double Room 15-29"< cout<<" 3. Studio Room 30-39"< cout<<" 4. Suite Room 40-49"< cout<>roomnum; while (roomnum<1 || roomnum>49) { cout<<"Room does not exist. Please re-enter : "; cin>>roomnum; } if (roomnum>=1 && roomnum<=14) type="SINGLE BED"; else if (roomnum>=15 && roomnum<=29) type="DOUBLE BED"; else if (roomnum>=30 && roomnum<=39) type="STUDIO"; else if (roomnum>=40 && roomnum<=49) type="SUITE"; return type; } void custRecord (System hotel[]) { cout< cout< for (int i=0; i<50; i++) { if (hotel[i].room==1) cout< } cout< return; } void roomStatus (System hotel[]) { int Room[5][10]={0}; int num=1; cout< for (int i=0; i<50; i++) if (hotel[i].room==1) { int row=i/10; int col=i%10; Room[row][col]=1; } for (int row=0; row<5, num<50; row++) { for (int col=1; col<=10; col++) { if (Room[row][col]==0) cout< else if (Room[row][col]==1) cout<<" X "; num++; } cout< } cout<<" X - Booked"< return; } void editRecord(System* hotel) { int j, choice; char key; cout< cout<<"Enter room number : "; cin>>j; if (hotel[j].room==1){ cout<<" Record for room "< cout<<" Customer name : "< cout<<" Phone number : "< cout<<"Press 1 to modify record"< cout<<"Press 2 to delete record"< cout<<"Choice (1/2) : "; cin>>choice; cout< if (choice==1) { cout<<"Enter new customer's name : "; cin>>hotel[j].name; cout<<"Enter new customer's phone number : "; cin>>hotel[j].phone; cout<<"RECORD SUCCESSFULLY MODIFIED"< } else if (choice==2) { hotel[j].room=0; cout<<"RECORD DELETED"< } } else { cout<<"No record for this room"< cout<<"Do you wish to continue (press Y for yes) : "; cin>>key; if (key=='y' || key=='Y') editRecord (hotel); } return; } void file (System hotel[]) { ofstream outFile; string filename = "hotel.txt"; outFile.open(filename.c_str()); if (outFile.fail()) { cout<<"hotel.txt can't be opened."< cout<<"Please check that the file currently exist."< exit(1); } outFile<<" CUSTOMER RECORD"< outFile< for (int i=0; i<50; i++) { if (hotel[i].room==1) outFile< } outFile.close(); cout< return; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
