You are on page 1of 13

#include<iostream.

h>
#include<conio.h>
#include<string.h>
#include<stdio.h>
#include<process.h>
#include<fstream.h>
struct logindata // please note the password : tps
{
char username[10];
char password[10];
};
void login();
void login()
{
clrscr() ;
char pass1, pass2, pass3 ;
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\t\t\t\tPlease Enter the password : " ;
pass1=getch() ;
cout<<"*" ;
pass2=getch() ;
cout<<"*" ;
pass3=getch() ;
cout<<"*" ;
getch();
if (pass1 == 't' && pass2 == 'p' && pass3 == 's')
{
return;
}
clrscr();
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\t\t\t\tWRONG PASSWORD!!!!";
cout<<endl;
getch() ;
exit(0) ;
}
class hotel
{
char id[20];
int rno;
int bil;
int ser;
int days;
int total;
int price;
char type[20];
char name[30];
char address[50];
char phone[10];
public:
void main_menu(); //to dispay the main menu
void add(); //to book a room
void display(); //to display the customer record
void rooms(); //to display alloted rooms
void available();
void edit(); //to edit the customer record
int check(int); //to check room status
void modify(int); //to modify the record

void bill();
void display_bill(int);
void pay_bill(int);
void delete_rec(int); //to delete the record
void r_type();
int test();
int getroomno()
{
return rno;
}
void r1()
{cout<<"\n-----------------------------------------------------------------";
cout<<"\n\n\t\t\t\t\t GENERAL ";
cout<<"\n-------------------------------------------------------------------";
cout<<"\n Room no.=1";
cout<<"\n\n Room charges=Rs.750 per day";
cout<<"\n\n 1. No. of Bed=2";
cout<<"\n\n 2.Capacity=3";
cout<<"\n------------------------------------------------------------------";
cout<<"\n\t\t\t\tADDITIONAL FEATURES";
cout<<"\n------------------------------------------------------------------";
cout<<"\n\n 1.Geyser available";
getch();
}
void r2()
{cout<<"\n-----------------------------------------------------------------";
cout<<"\n\n\t\t\t\tDELUXE ";
cout<<"\n-----------------------------------------------------------------";
cout<<"\nRoom No.=2";
cout<<"\n\n Room charges=Rs.1000 per day";
cout<<"\n\n 1. No.of Bed=2";
cout<<"\n\n 2.Capacity=5";
cout<<"\n-------------------------------------------------------------------";
cout<<"\n ADDITIONAL FEATURES ";
cout<<"\n-------------------------------------------------------------------";
cout<<"\n\n 1.A/C avaalable ";
cout<<"\n\n 3.Geyser available";
cout<<"\n\n 4.TV available ";
getch();
}
void r3()
{cout<<"\n------------------------------------------------------------------";
cout<<"\n\n\t\t\tSUPER DELUXE";
cout<<"\n------------------------------------------------------------------";
cout<<"\n Room No.=3";
cout<<"\n\n Room charges= Rs.1500 per day";
cout<<"\n\n 1.No.of Bed=2";
cout<<"\n\n 2.Capacity=4";
cout<<"\n\n 3.Balcony available ";
cout<<"\n------------------------------------------------------------------";
cout<<"\n ADDITIONAL FEATURES ";
cout<<"\n------------------------------------------------------------------";
cout<<"\n\n 1.A/C available ";
cout<<"\n\n 2.Geyser available";
cout<<"\n\n 3.TV available ";
getch();
}
void r4()
{cout<<"\n------------------------------------------------------------------";
cout<<"\n\n\t\t\t\t COUPLE";

cout<<"\n------------------------------------------------------------------";
cout<<"\nRoom No.=4";
cout<<"\n\n Room charges=Rs.1250 per day";
cout<<"\n\n 1. No. of Bed=2";
cout<<"\n\n 2. Capacity=2";
cout<<"\n\n 3.Balcony available ";
cout<<"\n------------------------------------------------------------------";
cout<<"\n ADDITIONAL FEATURES ";
cout<<"\n------------------------------------------------------------------";
cout<<"\n\n 1.Geyser available";
cout<<"\n\n 2.TV available ";
getch();
}
void r5()
{cout<<"\n------------------------------------------------------------------";
cout<<"\n\n\t\t\t\t COUPLE DELUX";
cout<<"\n------------------------------------------------------------------";
cout<<"\nRoom No.=5";
cout<<"\n\n Room charges=Rs.1500 per day";
cout<<"\n\n 1.No. of Bed=2";
cout<<"\n\n 2.Capacity=2";
cout<<"\n\n 3.Balcony available ";
cout<<"\n------------------------------------------------------------------";
cout<<"\n ADDITIONAL FEATURES ";
cout<<"\n------------------------------------------------------------------";
cout<<"\n\n 1.A/C available ";
cout<<"\n\n 2.Geyser available";
cout<<"\n\n 3.TV available ";
getch();
}}obj;
void hotel::main_menu()
{
int choice;
while(choice!=7)
{
clrscr();
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\t1.Book A Room";
cout<<"\n\t\t\t2.Customer Record";
cout<<"\n\t\t\t3.Rooms Allotted";
cout<<"\n\t\t\t4.Rooms Available";
cout<<"\n\t\t\t5.Edit Record";
cout<<"\n\t\t\t6.Room Facilities";
cout<<"\n\t\t\t7.Customer Bill";
cout<<"\n\t\t\t8.Exit";
cout<<"\n\n\t\t\tEnter Your Choice: ";
cin>>choice;
switch(choice)
{
case 1: add();
break;
case 2: display();
break;
case 3: rooms();
break;
case 4: available();
break;
case 5: edit();

break;
case 6:r_type();
break;
case 7:bill();
break;
case 8: return;
default:
{
cout<<"\n\n\t\t\tWrong choice.....!!!";
cout<<"\n\t\t\tPress any key to continue....!!";
getch();
}
}
}
}
void hotel::r_type()
{
int ch;
while(ch!=6)
{
clrscr();
cout<<"\n=======================================================================
=========";
cout<<"\n\t\t\t\tTYPES OF THE ROOM";
cout<<"\n=======================================================================
=========";
cout<<"\n\n\n\t\t\t\t1.General";
cout<<"\n\t\t\t\t2.Deluxe";
cout<<"\n\t\t\t\t3.Super Deluxe";
cout<<"\n\t\t\t\t4.Couple ";
cout<<"\n\t\t\t\t5.Cpuple Deluxe";
cout<<"\n\t\t\t\t6.Back to main menu";
cout<<"\n\n Enter your choice to view the details of the room....";
cin>>ch;
switch(ch)
{
case 1: clrscr();
r1();
break;
case 2:clrscr();
r2();
break;
case 3:
clrscr();
r3();
break;
case 4:
clrscr();
r4();
break;
case 5 :
clrscr();
r5();
break;
case 6:
getch();
break;
default:
{
cout<<"\n Wrong choice";;

getch();
}
}
}
}
void hotel::add()
{
clrscr();
int rn,e;
ofstream fout("rooms.dat",ios::app);
cout<<"\t\t\tDETAILS OF THE ROOM";
cout<<"\n\t\t\t--------------------";
cout<<"\n\nRoom No.\t\t\t\tRoom Type";
cout<<"\n\n\n1\t\t\t\t\tGeneral";
cout<<"\n2\t\t\t\t\tDelux";
cout<<"\n3\t\t\t\t\tSuper Delux";
cout<<"\n4\t\t\t\t\tCouple";
cout<<"\n5\t\t\t\t\tCouple Delux";
cout<<"\n-----------------------------------------------------------------";
cout<<"\n\n\t\t\tREGISTER";
cout<<"\n\nEnter Room no. you want to book: ";
cin>>rn;
if((rn<1)|| (rn>5))
{
cout<<"\nInvalid room number....Please Try Again";
getch();
return;
}
e=check(rn);
if(e)
cout<<"\n Sorry..!!!Room is already booked";
else
{
rno=rn;
cout<<"\n\n\t\t\tRoom Available!!!!!!";
cout<<"\nEnter room Type Displayed Above:";
gets(type);
cout<<"\n\nEnter your name:";
gets(name);
cout<<"\nEnter your address:";
gets(address);
cout<<"\nEnter your Phone number:";
cin>>phone;
cout<<"\nEnter your Email id:";
gets(id);
cout<<"\nHow many days you want to live???\n";
cin>>days;
if(rno==1)
{r1();
price=750;
}
else if(rno==2)
{
r2();
price=1000;}

else if(rno==3)
{
r3();
price=1500;
}
else if(rno==4)
{
r4();
price=1250;}
else if(rno==5)
{
r5();
price=1500;
}
else
cout<<"\nInvalid room number....Please Try Again";
getch();
fout.write((char*)this,sizeof(hotel));
cout<<"\nYour Room is booked...!!!";
}
cout<<"\n\n\n Press any key to continue.....!!";
getch();
fout.close();
}
void hotel::display()
{
clrscr();
ifstream fin("rooms.dat",ios::in);
int rn,e;
cout<<"\n Enter Your room no: ";
cin>>rn;
while(!fin.eof())
{
fin.read((char*)this,sizeof(hotel));
if(rno==rn)
{
clrscr();
cout<<"\n\t\t\t\tRoom Details";
cout<<"\n\nRoom no: "<<rno;
cout<<"\nRoom Type:"<<type;
cout<<"\nCustomer Name:"<<name;
cout<<"\nCustomer Address:"<<address;
cout<<"\nPhone number:"<<phone;
cout<<"\nEmail ID:"<<id;
cout<<"\nNumber of days living:"<<days;
cout<<"\n Room Charge:Rs."<<price<<" \\-";
e=1;
break;
}
}
if(e==0)
cout<<"\n Sorry Room no. not found or vacant....!!";
cout<<"\n\n Press any key to continue....!!";

getch();
fin.close();
}
int hotel::test()
//FIND NO. OF RECORDS
{
ifstream fin;
fin.open("rooms.dat");
fin.seekg(0,ios::end);
int n;
n=fin.tellg()/sizeof(obj);
cout<<" \n NUMBER OF RECORDS = "<<n ;
return n ;
}
void hotel::rooms()
{
clrscr();
int n;
ifstream fin("rooms.dat",ios::in);
cout<<"\n\t\t\t
=====================";
cout<<"\n\t\t\t
LIST OF ROOMS ALLOTED";
cout<<"\n\t\t\t
=====================";
n=test();
cout<<"\n\nRoom No.\t\tName\t\tType\t\tRoom_charge\n";
if(fin)
{
for(int i=0;i<n;i++)
{
fin.read((char*)this,sizeof(hotel));
cout<<"\n\n "<<rno<<"\t\t\t"<<name<<"\t\t"<<type<<"\t\t"<<price;
}
}
cout<<"\n\n\nPress any key to continue.....!!";
getch();
fin.close();
}
void hotel::available()
{
clrscr();
int n; int f1=0,f2=0,f3=0,f4=0,f5=0;
ifstream fin("rooms.dat",ios::in);
cout<<"\n\t\t\t
=====================";
cout<<"\n\t\t\t
LIST OF ROOMS AVAILABLE";
cout<<"\n\t\t\t
=====================";
n=test();
cout<<"\n\nRoom No.\t\tType\t\tName\t\tRoom Available\n";
if(fin)
{
for(int i=0;i<n;i++)
{
fin.read((char*)&obj,sizeof(obj));
if(obj.getroomno()==1)
{
cout<<"\n\n "<<rno<<"\t\t\t"<<type<<"\t\t"<<name<<"\t\tY";
f1=1;
}

if(obj.getroomno()==2)
{
f2=1;
cout<<"\n\n "<<rno<<"\t\t\t"<<type<<"\t\t"<<name<<"\t\tY";
}
if(obj.getroomno()==3)
{
f3=1;
cout<<"\n\n "<<rno<<"\t\t\t"<<type<<"\t\t"<<name<<"\t\tY";
}
if(obj.getroomno()==4)
{
f4=1;
cout<<"\n\n "<<rno<<"\t\t\t"<<type<<"\t\t"<<name<<"\t\tY";
}
if(obj.getroomno()==5)
{
f5=1;
cout<<"\n\n "<<rno<<"\t\t\t"<<type<<"\t\t"<<name<<"\t\tY";
}
}
if(f1==0)
cout<<"\n\n
if(f2==0)
cout<<"\n\n
if(f3==0)
cout<<"\n\n
if(f4==0)
cout<<"\n\n
if(f5==0)
cout<<"\n\n

"<<"1"<<"\t\t\t"<<"GENERAL"<<"\t\t\t\tN";
"<<"2"<<"\t\t\t"<<"DELUX"<<"\t\t\t\tN";
"<<"3"<<"\t\t\t"<<"SUPER DELUX"<<"\t\t\tN";
"<<"4"<<"\t\t\t"<<"COUPLE"<<"\t\t\t\tN";
"<<"5"<<"\t\t\t"<<"COUPLE DELUX"<<"\t\t\tN";

}
cout<<"\n\n\nPress any key to continue.....!!";
getch();
fin.close();
}
void hotel::edit()
{
clrscr();
int choice;
int rn;
cout<<"\n\t\t\t\t ---------";
cout<<"\n\t\t\t\t EDIT MENU";
cout<<"\n\t\t\t\t ---------";
cout<<"\n\n\t\t\t\t1.Modify Record";
cout<<"\n\t\t\t\t2.Delete Record";
cout<<"\n\n\t\t\t\tEnter your choice: ";
cin>>choice;
clrscr();
cout<<"\n Enter your Room no.-" ;
cin>>rn;;
switch(choice)
{
case 1: modify(rn);
break;
case 2: delete_rec(rn);

break;
default: cout<<"\n Wrong Choice.....!!";
}
cout<<"\n Press any key to continue....!!!";
getch();
}
int hotel::check(int rn)
{
int e=0;
ifstream fin("rooms.dat",ios::in);
while(!fin.eof())
{
fin.read((char*)this,sizeof(hotel));
if(rno==rn)
{
e=1;
break;
}
}
fin.close();
return(e);
}
void hotel::modify(int rn)
{
long posi,e=0;
fstream file("rooms.dat",ios::in|ios::out|ios::binary);
while(!file.eof())
{
posi=file.tellg();
file.read((char*)this,sizeof(hotel));
if(rno==rn)
{
cout<<"\t\t\tDETAILS OF THE ROOM";
cout<<"\n\t\t\t--------------------";
cout<<"\n\nRoom No.\t\t\t\tRoom Type";
cout<<"\n\n\n1\t\t\t\t\tGeneral";
cout<<"\n2\t\t\t\t\tDelux";
cout<<"\n3\t\t\t\t\tSuper Delux";
cout<<"\n4\t\t\t\t\tCouple";
cout<<"\n5\t\t\t\t\tCouple Delux";
cout<<"\n-----------------------------------------------------------------";
cout<<"\n\t\t\tCustomer Name:"<<name;
cout<<"\n Enter New Details";
cout<<"\n\nEnter new Room no.: ";
cin>>rno;
cout<<"\nEnter new room type displayed above:";
gets(type);
cout<<"\nEnter new Address:";
cin>>address;
cout<<"How many days do you want to live???\n";
cin>>days;
cout<<"\nEnter new phone number:";
cin>>phone;
cout<<"\nEnter New Email ID:";

gets(id);
if(rn==1)
{r1();
price=750;
}
else if(rno==2)
{
r2();
price=1000;}
else if(rno==3)
{
r3();
price=1500;
}
else if(rno==4)
{
r4();
price=1250;}
else if(rno==5)
{
r5();
price=1500;
}
file.seekg(posi);
file.write((char*)this,sizeof(hotel));
cout<<"\n Your Record is modified....!!";
e=1;
break;
}
}
if(e==0)
cout<<"\n Sorry!! not found...!!";
file.close();
}
void hotel::delete_rec(int rn)
{
int e=0;
char ch;
ifstream fin("rooms.dat",ios::in);
ofstream fout("temp.dat",ios::out);
while(!fin.eof())
{
fin.read((char*)this,sizeof(hotel));
if(rno==rn)
{
cout<<"\n Room no.= "<<rno;
cout<<"\nCustomer Name:"<<name;
cout<<"\nCustomer address:"<<address;
cout<<"\nCustomer Phone number:"<<phone;
cout<<"\nRoom Type:"<<type;
cout<<"\nRoom Charge:Rs. "<<price<<" \\-";
cout<<"\nEmail ID:"<<id;
cout<<"\n Number of days living:"<<days;
cout<<"\n\n Do you want to delete this record(y/n): ";
cin>>ch;

if(ch=='n')
fout.write((char*)this,sizeof(hotel));
e=1;
}
else
fout.write((char*)this,sizeof(hotel));
}
fin.close();
fout.close();
if(e==0)
cout<<"\n Sorry!! not found ...!!";
else
{
remove("rooms.dat");
rename("temp.dat","rooms.dat");
}
}
void hotel::bill()
{
clrscr();
int choice;
int rn;
cout<<"\n\t\t\t\t-------------";
cout<<"\n\t\t\t\tCUSTOMER BILL";
cout<<"\n\t\t\t\t-------------";
cout<<"\n\n\t\t\t\t1.diasplay Bill";
cout<<"\n\t\t\t\t2.Pay Bill";
cout<<"\n\n\n\t\t\t\tEnter your choice: ";
cin>>choice;
clrscr();
cout<<"\n Enter your Room no.-" ;
cin>>rn;;
switch(choice)
{
case 1: display_bill(rn);
break;
case 2:pay_bill(rn);
break;
default: cout<<"\n Wrong Choice.....!!";
}
cout<<"\n Press any key to continue....!!!";
getch();
}
void hotel::pay_bill(int rn)
{
int e=0;
char ch;
ifstream fin("rooms.dat",ios::in);
ofstream fout("temp.dat",ios::out);
while(!fin.eof())
{
fin.read((char*)this,sizeof(hotel));
if(rno==rn)
{
clrscr();
bil=price*days;

ser=0.103*bil;
total=bil+ser;
cout<<"\n\t\t\t\t\t========";
cout<<"\n\t\t\t\t\tPAY BILL";
cout<<"\n\t\t\t\t\t========";
cout<<"\n\nRoom no: "<<rno;
cout<<"\nRoom Type:"<<type;
cout<<"\nCustomer Name:"<<name;
cout<<"\nCustomer Address:"<<address;
cout<<"\nPhone number:"<<phone;
cout<<"\nEmail ID:"<<id;
cout<<"\nNumber of days living:"<<days;
cout<<"\nRoom charge:Rs."<<price<<" \\-";
cout<<"\nSer.tax % =10.3%";
cout<<"\nSer.tax=Rs."<<ser<< "\\-";
cout<<"\n\n\nTotal bill you have to pay is Rs."<<total<<" \\-";
cout<<"\n\n Are you sure you Pay your bill???(y/n): ";
cin>>ch;
if(ch=='n')
fout.write((char*)this,sizeof(hotel));
e=1;
}
else
fout.write((char*)this,sizeof(hotel));
}
fin.close();
fout.close();
if(e==0)
cout<<"\n Sorry!! not found ...!!";
else
{
cout<<"\nBill Paid.....";
cout<<"\n\t\t\t\t****Thank You****";
cout<<"\n\n\t\t\t\tCome Again!!!!!!";
remove("rooms.dat");
rename("temp.dat","rooms.dat");
}
}
void hotel::display_bill(int rn)
{
clrscr();
ifstream fin("rooms.dat",ios::in);
int e;
//
cout<<"\n Enter Your room no: ";
//
cin>>rn;
while(!fin.eof())
{
fin.read((char*)this,sizeof(hotel));
if(rno==rn)
{bil=price*days;
ser=0.103*bil;
total=bil+ser;
clrscr();
cout<<"\n\t\t\t\t\t============";

cout<<"\n\t\t\t\t\tDISPLAY BILL";
cout<<"\n\t\t\t\t\t============";
cout<<"\n\nRoom no: "<<rno;
cout<<"\nRoom Type:"<<type;
cout<<"\nCustomer Name:"<<name;
cout<<"\nCustomer Address:"<<address;
cout<<"\nPhone number:"<<phone;
cout<<"\nEmail ID:"<<id;
cout<<"\nNumber of days living:"<<days;
cout<<"\nRoom Charge:Rs."<<price<<" \\-";
cout<<"\nSer.tax % =10.3%";
cout<<"\nSer.tax=Rs."<<ser<<" \\-";
cout<<"\n\n\nTotal bill you have to pay is Rs."<<total<<" \\-";
e=1;
break;
}
}
if(e==0)
cout<<"\n Sorry Room no. not found....!!Please try again!!!";
//
cout<<"\n\n Press any key to continue....!!";
getch();
fin.close();
}
void main()
{
login();
hotel h;
clrscr();
cout<<"\n============================================================
====================";
cout<<"\n******************** WELCOME TO HOTEL MANAGEMENT SYSTEM ****
********************";
cout<<"\n============================================================
====================";
cout<<"\n\n\n\t\t\t\Tilak Public School,Nerul";
cout<<"\n\n\n\n\t\t\t\tMADE BY:-";
cout<<"\n\n\t\t\t\tClass-XII(Sci)";
cout<<"\n\n\tAkhil Ashokan\t\t\t\t\tEashwaran Sridharr";
cout<<"\n\tRoll No.-2\t\t\t\t\tRoll No.-7";
cout<<"\n\n\n\t\t\t\t\tPress any key to continue....!!";
getch();
h.main_menu();
}

You might also like