#include<iostream>#include<fstream>#include<stdio.
h>#include<stri
ng.h>#include<cstring>#include<iomanip>
using namespace std;
class HOTEL{
private:
int room_no;
char name[30];
char address[50];
char phone[15];
long days;
long cost;
char rtype[30];
long pay;
void breakfast(int); //to assign price of
breakfast
void lunch(int); //to assign price of lunch
void dinner(int); //to assign price of dinner
public:
void main_menu(); //to dispay the main menu
void add(); //to book a room
void display(); //to display the specific
customer information
void rooms(); //to display alloted
rooms
void edit(); //to edit the customer by
calling modify or delete
int check(int); //to check room status
void modify(); //to modify the customer
information
void delete_rec(); //to check out the
customer
void restaurant(); //to order food from
restaurant
void modify_name(int); //to modify name of
guest
void modify_address(int); //to modify address of
guest
void modify_phone(int); //to modify phone number
of guest
void modify_days(int); //to modify days of stay
of guest}h;
void HOTEL::main_menu(){
int choice;
while(choice!=6)
{
system("clear");
cout<<"\n\t\t\t\t *************";
cout<<"\n\t\t\t\t **THE HOTEL**";
cout<<"\n\t\t\t\t *************";
cout<<"\n\t\t\t\t * MAIN MENU *";
cout<<"\n\t\t\t\t *************";
cout<<"\n\n\n\t\t\t\t1. Book A Room";
cout<<"\n\t\t\t\t2. Customer Information";
cout<<"\n\t\t\t\t3. Rooms Allotted";
cout<<"\n\t\t\t\t4. Edit Customer Details";
cout<<"\n\t\t\t\t5. Order Food from Restaurant";
cout<<"\n\t\t\t\t6. Exit";
cout<<"\n\n\t\t\t\tEnter Your Choice: ";
cin>>choice;
switch(choice)
{
case 1: add();
break;
case 2: display();
break;
case 3: rooms();
break;
case 4: edit();
break;
case 5: restaurant();
break;
case 6: return;
default:
{
cout<<"\n\n\t\t\tWrong
choice.";
cout<<"\n\t\t\tPress any key
to continue.";
getchar();
}
}
}}
void HOTEL::add(){
system("clear");
int r,flag;
ofstream fout("[Link]",ios::app|ios::binary);
cout<<"\n\t\t\t +-----------------------+";
cout<<"\n\t\t\t | Rooms | Room Type |";
cout<<"\n\t\t\t +-----------------------+";
cout<<"\n\t\t\t | 1-50 | Deluxe |";
cout<<"\n\t\t\t | 51-80 | Executive |";
cout<<"\n\t\t\t | 81-100 | Presidential |";
cout<<"\n\t\t\t +-----------------------+";
cout<<"\n\n ENTER CUSTOMER DETAILS";
cout<<"\n ----------------------";
cout<<"\n\n Room Number: ";
cin>>r;
flag=check(r);
if(flag==1)
cout<<"\n Sorry, Room is already booked.\n";
else
{
if(flag==2)
cout<<"\n Sorry, Room does not exist.\n";
else
{
room_no=r;
cout<<" Name: ";
cin>>name;
cout<<" Address: ";
cin>>address;
cout<<" Phone Number: ";
cin>>phone;
cout<<" Number of Days: ";
cin>>days;
if(room_no>=1&&room_no<=50)
{
strcpy(rtype,"Deluxe");
cost=days*10000;
}
else
{
if(room_no>=51&&room_no<=80)
{
strcpy(rtype,"Executive");
cost=days*12500;
}
else
{
if(room_no>=81&&room_no<=100)
{
strcpy(rtype,"Presidential");
cost=days*15000;
}
}
}
[Link]((char*)this, sizeof(HOTEL));
cout<<"\n Room has been booked.";
}
}
cout<<"\n Press any key to continue.";
getchar();
getchar();
[Link]();}
void HOTEL::display(){
system("clear");
ifstream fin("[Link]",ios::in|ios::binary);
int r,flag;
cout<<"\n Enter Room Number: ";
cin>>r;
while([Link]((char*)this,sizeof(HOTEL)))
{
if(room_no==r)
{
system("clear");
cout<<"\n Customer Details";
cout<<"\n ----------------";
cout<<"\n\n Room Number: "<<room_no;
cout<<"\n Name: "<<name;
cout<<"\n Address: "<<address;
cout<<"\n Phone Number: "<<phone;
cout<<"\n Staying for "<<days<<" days.";
cout<<"\n Room Type: "<<rtype;
cout<<"\n Total cost of stay: "<<cost;
flag=1;
break;
}
}
if(flag==0)
cout<<"\n Room is Vacant.";
cout<<"\n\n Press any key to continue.";
getchar();
getchar();
[Link]();
}
void HOTEL::rooms(){
system("clear");
const char separator=' ';
const int NoWidth=8;
const int GuestWidth=17;
const int AddressWidth=16;
const int RoomWidth=13;
const int ContactNoWidth=13;
ifstream fin("[Link]",ios::in|ios::binary);
cout<<"\n\t\t\t LIST OF ROOMS ALLOTED";
cout<<"\n\t\t\t -----------------------";
cout<<"\n\n +---------+------------------
+-----------------+--------------+--------------+";
cout<<"\n | Room No.| Guest Name | Address |
Room Type | Contact No. |";
cout<<"\n +---------+------------------+-----------------
+--------------+--------------+";
while([Link]((char*)this,sizeof(HOTEL)))
{
cout<<"\n
|"<<setw(NoWidth)<<setfill(separator)<<room_no<<" |";
cout<<setw(GuestWidth)<<setfill(separator)<<name<<"
|";
cout<<setw(AddressWidth)<<setfill(separator)<<address<<"
|";
cout<<setw(RoomWidth)<<setfill(separator)<<rtype<<"
|";
cout<<setw(ContactNoWidth)<<setfill(separator)<<phone<<"
|";
}
cout<<"\n +---------+------------------+-----------------
+--------------+--------------+";
cout<<"\n\n\n\t\t\tPress any key to continue.";
getchar();
getchar();
[Link]();}
void HOTEL::edit(){
system("clear");
int choice,r;
cout<<"\n EDIT MENU";
cout<<"\n ---------";
cout<<"\n\n 1. Modify Customer Information.";
cout<<"\n 2. Customer Check Out.";
cout<<"\n Enter your choice: ";
cin>>choice;
system("clear");
switch(choice)
{
case 1: modify();
break;
case 2: delete_rec();
break;
default: cout<<"\n Wrong Choice.";
break;
}
cout<<"\n Press any key to continue.";
getchar();
getchar();}
int HOTEL::check(int r){
int flag=0;
ifstream fin("[Link]",ios::in|ios::binary);
while([Link]((char*)this,sizeof(HOTEL)))
{
if(room_no==r)
{
flag=1;
break;
}
else
{
if(r>100)
{
flag=2;
break;
}
}
}
[Link]();
return(flag);}
void HOTEL::modify(){
system("clear");
int ch,r;
cout<<"\n MODIFY MENU";
cout<<"\n -----------";
cout<<"\n\n\n 1. Modify Name";
cout<<"\n 2. Modify Address";
cout<<"\n 3. Modify Phone Number";
cout<<"\n 4. Modify Number of Days of Stay";
cout<<"\n Enter Your Choice: ";
cin>>ch;
system("clear");
cout<<"\n Enter Room Number: ";
cin>>r;
switch(ch)
{
case 1: modify_name(r);
break;
case 2: modify_address(r);
break;
case 3: modify_phone(r);
break;
case 4: modify_days(r);
break;
default: cout<<"\n Wrong Choice";
getchar();
getchar();
break;
}}
void HOTEL::modify_name(int r){
long pos,flag=0;
fstream file("[Link]",ios::in|ios::out|ios::binary);
while(![Link]())
{
pos=[Link]();
[Link]((char*)this,sizeof(HOTEL));
if(room_no==r)
{
cout<<"\n Enter New Name: ";
cin>>name;
[Link](pos);
[Link]((char*)this,sizeof(HOTEL));
cout<<"\n Customer Name has been
modified.";
flag=1;
break;
}
}
if(flag==0)
cout<<"\n Sorry, Room is vacant.";
getchar();
getchar();
[Link]();}
void HOTEL::modify_address(int r){
long pos,flag=0;
fstream file("[Link]",ios::in|ios::out|ios::binary);
while(![Link]())
{
pos=[Link]();
[Link]((char*)this,sizeof(HOTEL));
if(room_no==r)
{
cout<<"\n Enter New Address: ";
cin>>address;
[Link](pos);
[Link]((char*)this,sizeof(HOTEL));
cout<<"\n Customer Address has been
modified.";
flag=1;
break;
}
}
if(flag==0)
cout<<"\n Sorry, Room is vacant.";
getchar();
getchar();
[Link]();}
void HOTEL::modify_phone(int r){
long pos,flag=0;
fstream file("[Link]",ios::in|ios::out|ios::binary);
while(![Link]())
{
pos=[Link]();
[Link]((char*)this,sizeof(HOTEL));
if(room_no==r)
{
cout<<"\n Enter New Phone Number: ";
cin>>phone;
[Link](pos);
[Link]((char*)this,sizeof(HOTEL));
cout<<"\n Customer Phone Number has been
modified.";
flag=1;
break;
}
}
if(flag==0)
cout<<"\n Sorry, Room is vacant.";
getchar();
getchar();
[Link]();}
void HOTEL::modify_days(int r){
long pos,flag=0;
fstream file("[Link]",ios::in|ios::out|ios::binary);
while(![Link]())
{
pos=[Link]();
[Link]((char*)this,sizeof(HOTEL));
if(room_no==r)
{
cout<<" Enter New Number of Days of Stay:
";
cin>>days;
if(room_no>=1&&room_no<=50)
{
strcpy(rtype,"Deluxe");
cost=days*10000;
}
else
{
if(room_no>=51&&room_no<=80)
{
strcpy(rtype,"Executive");
cost=days*12500;
}
else
{
if(room_no>=81&&room_no<=100)
{
strcpy(rtype,"Presidential");
cost=days*15000;
}
}
}
[Link](pos);
[Link]((char*)this,sizeof(HOTEL));
cout<<"\n Customer information is
modified.";
flag=1;
break;
}
}
if(flag==0)
cout<<"\n Sorry, Room is Vacant.";
getchar();
getchar();
[Link]();}
void HOTEL::delete_rec(){
int r,flag=0;
char ch;
cout<<"\n Enter Room Number: ";
cin>>r;
ifstream fin("[Link]",ios::in|ios::binary);
ofstream fout("[Link]",ios::out|ios::binary);
while([Link]((char*)this,sizeof(HOTEL)))
{
if(room_no==r)
{
cout<<"\n Name: "<<name;
cout<<"\n Address: "<<address;
cout<<"\n Phone Number: "<<phone;
cout<<"\n Room Type: "<<rtype;
cout<<"\n Your total bill is: Rs. "<<cost;
cout<<"\n\n Do you want to check out this
customer(y/n): ";
cin>>ch;
if(ch=='n')
[Link]((char*)this,sizeof(HOTEL));
else
cout<<"\n Customer Checked Out.";
flag=1;
}
else
[Link]((char*)this,sizeof(HOTEL));
}
[Link]();
[Link]();
if(flag==0)
cout<<"\n Sorry, Room is Vacant.";
else
{
remove("[Link]");
rename("[Link]","[Link]");
}
getchar();
getchar();}
void HOTEL::restaurant(){
system("clear");
int r,ch,num;
cout<<"\n RESTAURANT MENU:";
cout<<"\n --------------- ";
cout<<"\n\n 1. Order Breakfast\n 2. Order Lunch\n 3. Order
Dinner";
cout<<"\n\n Enter your choice: ";
cin>>ch;
system("clear");
cout<<" Enter Room Number: ";
cin>>r;
switch(ch)
{
case 1: breakfast(r);
break;
case 2: lunch(r);
break;
case 3: dinner(r);
break;
}
cout<<"\n\n Press any key to continue.";
getchar();
getchar();
return;}
void HOTEL::breakfast(int r){
int num,flag=0;
long pos;
cout<<" Enter number of people: ";
cin>>num;
fstream file("[Link]",ios::in|ios::out|ios::binary);
while(![Link]())
{
pos=[Link]();
[Link]((char*)this,sizeof(HOTEL));
if(room_no==r)
{
pay=500*num;
cost=cost+pay;
[Link](pos);
[Link]((char*)this,sizeof(HOTEL));
cout<<"\n Amount added to the bill: Rs.
"<<pay;
flag=1;
break;
}
}
if(flag==0)
cout<<"\n Sorry, Room is Vacant.";
getchar();
getchar();
[Link]();}
void HOTEL::lunch(int r){
int num,flag=0;
long pos;
cout<<" Enter number of people: ";
cin>>num;
fstream file("[Link]",ios::in|ios::out|ios::binary);
while(![Link]())
{
pos=[Link]();
[Link]((char*)this,sizeof(HOTEL));
if(room_no==r)
{
pay=1000*num;
cost=cost+pay;
[Link](pos);
[Link]((char*)this,sizeof(HOTEL));
cout<<"\n Amount added to the bill: Rs.
"<<pay;
flag=1;
break;
}
}
if(flag==0)
cout<<"\n Sorry, Room is vacant.";
getchar();
getchar();
[Link]();}
void HOTEL::dinner(int r){
int num,flag=0;
long pos;
cout<<" Enter number of people: ";
cin>>num;
fstream file("[Link]",ios::in|ios::out|ios::binary);
while(![Link]())
{
pos=[Link]();
[Link]((char*)this,sizeof(HOTEL));
if(room_no==r)
{
pay=1200*num;
cost=cost+pay;
[Link](pos);
[Link]((char*)this,sizeof(HOTEL));
cout<<"\n Amount added to the bill: Rs.
"<<pay;
flag=1;
break;
}
}
if(flag==0)
cout<<"\n Sorry, Room is Vacant.";
getchar();
getchar();
[Link]();}
int main(){
system("clear");
h.main_menu();
return 0;}
#include<iostream>
#include<string.h>
#define max 100
using namespace std;
//Class Customer
class Customer
{
public:
char name[100];
char address[100];
char phone[12];
char from_date[20];
char to_date[20];
float payment_advance;
int booking_id;
};
class Room
{
public:
char type;
char stype;
char ac;
int roomNumber;
int rent;
int status;
class Customer cust;
class Room addRoom(int);
void searchRoom(int);
void deleteRoom(int);
void displayRoom(Room);
};
//Global Declarations
class Room rooms[max];
int count=0;
Room Room::addRoom(int rno)
{
class Room room;
[Link]=rno;
cout<<"\nType AC/Non-AC (A/N) : ";
cin>>[Link];
cout<<"\nType Comfort (S/N) : ";
cin>>[Link];
cout<<"\nType Size (B/S) : ";
cin>>[Link];
cout<<"\nDaily Rent : ";
cin>>[Link];
[Link]=0;
cout<<"\n Room Added Successfully!";
return room;
}
void Room::searchRoom(int rno)
{
int i,found=0;
for(i=0;i<count;i++)
{
if(rooms[i].roomNumber==rno)
{
found=1;
break;
}
}
if(found==1)
{
cout<<"Room Details\n";
if(rooms[i].status==1)
{
cout<<"\nRoom is Reserved";
}
else
{
cout<<"\nRoom is available";
}
displayRoom(rooms[i]);
}
else
{
cout<<"\nRoom not found";
}
}
void Room::displayRoom(Room tempRoom)
{
cout<<"\nRoom Number: \t"<<[Link];
cout<<"\nType AC/Non-AC (A/N) "<<[Link];
cout<<"\nType Comfort (S/N) "<<[Link];
cout<<"\nType Size (B/S) "<<[Link];
cout<<"\nRent: "<<[Link];
}
//hotel management class
class HotelMgnt:protected Room
{
public:
void checkIn();
void getAvailRoom();
void searchCustomer(char *);
void checkOut(int);
void guestSummaryReport();
};
void HotelMgnt::guestSummaryReport(){
if(count==0){
cout<<"\n No Guest in Hotel !!";
}
for(int i=0;i<count;i++)
{
if(rooms[i].status==1)
{
cout<<"\n Customer First Name : "<<rooms[i].[Link];
cout<<"\n Room Number : "<<rooms[i].roomNumber;
cout<<"\n Address (only city) : "<<rooms[i].[Link];
cout<<"\n Phone : "<<rooms[i].[Link];
cout<<"\n---------------------------------------";
}
//hotel management reservation of room
void HotelMgnt::checkIn()
{
int i,found=0,rno;
class Room room;
cout<<"\nEnter Room number : ";
cin>>rno;
for(i=0;i<count;i++)
{
if(rooms[i].roomNumber==rno)
{
found=1;
break;
}
}
if(found==1)
{
if(rooms[i].status==1)
{
cout<<"\nRoom is already Booked";
return;
}
cout<<"\nEnter booking id: ";
cin>>rooms[i].cust.booking_id;
cout<<"\nEnter Customer Name (First Name): ";
cin>>rooms[i].[Link];
cout<<"\nEnter Address (only city): ";
cin>>rooms[i].[Link];
cout<<"\nEnter Phone: ";
cin>>rooms[i].[Link];
cout<<"\nEnter From Date: ";
cin>>rooms[i].cust.from_date;
cout<<"\nEnter to Date: ";
cin>>rooms[i].cust.to_date;
cout<<"\nEnter Advance Payment: ";
cin>>rooms[i].cust.payment_advance;
rooms[i].status=1;
cout<<"\n Customer Checked-in Successfully..";
}
}
//hotel management shows available rooms
void HotelMgnt::getAvailRoom()
{
int i,found=0;
for(i=0;i<count;i++)
{
if(rooms[i].status==0)
{
displayRoom(rooms[i]);
cout<<"\n\nPress enter for next room";
found=1;
}
}
if(found==0)
{
cout<<"\nAll rooms are reserved";
}
}
//hotel management shows all persons that have booked room
void HotelMgnt::searchCustomer(char *pname)
{
int i,found=0;
for(i=0;i<count;i++)
{
if(rooms[i].status==1 &&
strcmp(rooms[i].[Link],pname)==0)
{
cout<<"\nCustomer Name: "<<rooms[i].[Link];
cout<<"\nRoom Number: "<<rooms[i].roomNumber;
cout<<"\n\nPress enter for next record\n";
found=1;
}
}
if(found==0)
{
cout<<"\nPerson not found.\n";
}
}
//hotel managemt generates the bill of the expenses
void HotelMgnt::checkOut(int roomNum)
{
int i,found=0,days,rno;
float billAmount=0;
for(i=0;i<count;i++)
{
if(rooms[i].status==1 &&
rooms[i].roomNumber==roomNum)
{
//rno = rooms[i].roomNumber;
found=1;
//getch();
break;
}
}
if(found==1)
{
cout<<"\nEnter Number of Days:\t";
cin>>days;
billAmount=days * rooms[i].rent;
cout<<"\n\t######## CheckOut Details ########\n";
cout<<"\nCustomer Name : "<<rooms[i].[Link];
cout<<"\nRoom Number : "<<rooms[i].roomNumber;
cout<<"\nAddress : "<<rooms[i].[Link];
cout<<"\nPhone : "<<rooms[i].[Link];
cout<<"\nTotal Amount Due : "<<billAmount<<" /";
cout<<"\nAdvance Paid:
"<<rooms[i].cust.payment_advance<<" /";
cout<<"\n*** Total Payable: "<<billAmount-
rooms[i].cust.payment_advance<<"/ only";
rooms[i].status=0;
}
}
//managing rooms (adding and searching available rooms)
void manageRooms()
{
class Room room;
int opt,rno,i,flag=0;
char ch;
do
{
cout<<"\n### Manage Rooms ###";
cout<<"\n1. Add Room";
cout<<"\n2. Search Room";
cout<<"\n3. Back to Main Menu";
cout<<"\n\nEnter Option: ";
cin>>opt;
//switch statement
switch(opt)
{
case 1:
cout<<"\nEnter Room Number: ";
cin>>rno;
i=0;
for(i=0;i<count;i++)
{
if(rooms[i].roomNumber==rno)
{
flag=1;
}
}
if(flag==1)
{
cout<<"\nRoom Number is Present.\nPlease enter unique
Number";
flag=0;
}
else
{
rooms[count]=[Link](rno);
count++;
}
break;
case 2:
cout<<"\nEnter room number: ";
cin>>rno;
[Link](rno);
break;
case 3:
//nothing to do
break;
default:
cout<<"\nPlease Enter correct option";
break;
}
}while(opt!=3);
}
using namespace std;
int main()
{
class HotelMgnt hm;
int i,j,opt,rno;
char ch;
char pname[100];
do
{
cout<<"######## Hotel Management #########\n";
cout<<"\n1. Manage Rooms";
cout<<"\n2. Check-In Room";
cout<<"\n3. Available Rooms";
cout<<"\n4. Search Customer";
cout<<"\n5. Check-Out Room";
cout<<"\n6. Guest Summary Report";
cout<<"\n7. Exit";
cout<<"\n\nEnter Option: ";
cin>>opt;
switch(opt)
{
case 1:
manageRooms();
break;
case 2:
if(count==0)
{
cout<<"\nRooms data is not available.\nPlease add the rooms
first.";
}
else
[Link]();
break;
case 3:
if(count==0)
{
cout<<"\nRooms data is not available.\nPlease add the rooms
first.";
}
else
[Link]();
break;
case 4:
if(count==0)
{
cout<<"\nRooms are not available.\nPlease add the rooms
first.";
}
else
{
cout<<"Enter Customer Name: ";
cin>>pname;
[Link](pname);
}
break;
case 5:
if(count==0)
{
cout<<"\nRooms are not available.\nPlease add the rooms
first.";
}
else
{
cout<<"Enter Room Number : ";
cin>>rno;
[Link](rno);
}
break;
case 6:
[Link]();
break;
case 7:
cout<<"\nTHANK YOU! FOR USING SOFTWARE\n";
break;
default:
cout<<"\nPlease Enter correct option";
break;
}
}while(opt!=7);