This is a simple hotel management program of C++. Below

This is a simple hotel management program of C++. Below real code is given of the program. Draw a flowchart and block diagram of the program. Snaps of Flow chart and block diagram should be clear in reading. Point out any major mistake in the end in code if found. In case to run the program, Dev C++ is preferred after deleting comments from code. Thanks for co-operation.

#include
#include
#include
#include
#include
#include

using namespace std;

//START OF CLASS

class hotel
{

int room_no;
char name[30];
char address[50];
char phone[10];

public:

void main_menu(); //to display the main menu
void add(); //to book a room
void display(); //to display the customer record
void rooms(); //to display allotted rooms
void edit(); //to edit the customer record
int check(int); //to check room status
void modify(int); //to modify the record
void delete_rec(int); //to delete the record
void bill(int); //for the bill of a record
};
//END OF CLASS

//FOR DISPLAYING MAIN MENU

void hotel::main_menu()
{

int choice;
while(choice!=5)
{

system(“cls”);
cout<>
cout<“ttt simple=”” hotel=”” management=””>
cout<“ttt *=”” main=”” menu=””>
cout<>
cout<“tt1.book a=””>
cout<“tt2.customer>
cout<“tt3.rooms>
cout<“tt4.edit>
cout<>
cout<“tttenter your=”” choice:=””>
cin>>choice;

switch(choice)
{

case 1: add();
break;

case 2: display();
break;

case 3: rooms();
break;

case 4: edit();
break;

case 5: break;

default:
{

cout<“tttwrong>
cout<“ttpress any=”” key=”” to=””>
getch();

}

}

}

}

//END OF MENU FUNCTION

//FUNCTION FOR BOOKING OF ROOM

void hotel::add()
{

system(“cls”);
int r,flag;
ofstream fout(“Record.dat”,ios::app);

cout<” enter=”” customer=””>
cout<“>
cout<” room=”” no:=””>
cout<” total=”” no.=”” of=”” rooms=”” -=””>
cout<” ordinary=”” rooms=”” from=”” 1=”” -=””>
cout<” luxuary=”” rooms=”” from=”” 31=”” -=””>
cout<” royal=”” rooms=”” from=”” 46=”” -=””>
cout <” enter=”” the=”” room=”” no.=”” you=”” want=”” to=”” stay=”” in=”” :-=””><>
cin>>r;

flag=check(r);

if(flag)
cout<” sorry..!!!room=”” is=”” already=””>

else
{

room_no=r;
cout<” name:=””>
cin>>name;
cout<” address:=””>
cin>>address;
cout<” phone=”” no:=””>
cin>>phone;

fout.write((char*)this,sizeof(hotel));
cout<” room=”” is=””>

}

cout<” press=”” any=”” key=”” to=””>

getch();
fout.close();

}

//END OF BOOKING FUNCTION

//FUNCTION FOR DISPLAYING A PURTICULAR CUSTOMER`S RECORD

void hotel::display()
{

system(“cls”);

ifstream fin(“Record.dat”,ios::in);
int r,flag;

cout<” enter=”” room=”” no.=”” for=”” a=”” particular=”” customer`s=”” details=”” :-=””><>
cin>>r;

while(!fin.eof())
{

fin.read((char*)this,sizeof(hotel));
if(room_no==r)
{

system(“cls”);
cout<” cusromer=””>
cout<“>
cout<” room=”” no:=””><>
cout<” name:=””><>
cout<” address:=””><>
cout<” phone=”” no:=””><>
flag=1;
break;

}

}

if(flag==0)
cout<” sorry=”” room=”” no.=”” not=”” found=”” or=””>
cout<” press=”” any=”” key=”” to=””>

getch();
fin.close();
}

//END OF DISPLAY FUNCTION

//FUNCTION TO DISPLAY ALL ROOMS OCCUPIED

void hotel::rooms()
{

system(“cls”);

ifstream fin(“Record.dat”,ios::in);
cout<“tt list=”” of=”” rooms=””>
cout<“tt>
cout<” room=”” no.amettaddressttttphone=””>

while(!fin.eof())
{

fin.read((char*)this,sizeof(hotel));
cout<“><><><>
cout<><><><>

}

cout<“ttpress any=”” key=”” to=””>
getch();
fin.close();

}

//FUNCTION FOR EDITING RECORDS AND FOR BILL

void hotel::edit()
{

system(“cls”);

int choice,r;
cout<” edit=””>
cout<“>
cout<” 1.modify=”” customer=””>
cout<” 2.delete=”” customer=””>
cout<” 3.=”” bill=”” of=””>
cout<” enter=”” your=”” choice:=””>

cin>>choice;
system(“cls”);

cout<” enter=”” room=”” no:=”” “=””>
cin>>r;

switch(choice)
{

case 1: modify(r);
break;

case 2: delete_rec(r);
break;

case 3: bill(r);
break;

default: cout<” wrong=””>

}
cout<” press=”” any=”” key=”” to=””>

getch();
}

int hotel::check(int r)
{

int flag=0;

ifstream fin(“Record.dat”,ios::in);

while(!fin.eof())
{

fin.read((char*)this,sizeof(hotel));
if(room_no==r)
{

flag=1;
break;

}

}

fin.close();
return(flag);

}

//FUNCTION TO MODIFY CUSTOMERS RECORD

void hotel::modify(int r)
{

long pos,flag=0;

fstream file(“Record.dat”,ios::in|ios::out|ios::binary);

while(!file.eof())
{

pos=file.tellg();
file. Read((char*)this,sizeof(hotel));

if(room_no==r)
{

cout<” enter=”” new=””>
cout<“>
cout<” name:=””>
cin>>name;
cout<” address:=””>
cin>>address;
cout<” phone=”” no:=””>
cin>>phone;
file.seekg(pos);
file. Write((char*)this,sizeof(hotel));
cout<” record=”” is=””>
flag=1;
break;

}

}

if(flag==0)
cout<” sorry=”” room=”” no.=”” not=”” found=”” or=””>
file.close();

}

//END OF MODIFY FUNCTION

//FUNCTION FOR DELETING RECORD

void hotel::delete_rec(int r)
{

int flag=0;
char ch;
ifstream fin(“Record.dat”,ios::in);
ofstream fout(“temp.dat”,ios::out);

while(!fin.read())
{

fin.read((char*)this,sizeof(hotel));
if(room_no==r)

{

cout<” name:=””><>
cout<” address:=””><>
cout<” pone=”” no:=””><>
cout<” do=”” you=”” want=”” to=”” delete=”” this=”” record(y/n):=””>
cin>>ch;

if(ch==’n’)
fout.write((char*)this,sizeof(hotel));
flag=1;

}

else
fout.write((char*)this,sizeof(hotel));

}

fin.close();
fout.close();

if(flag==0)
cout<” sorry=”” room=”” no.=”” not=”” found=”” or=””>

else
{

remove(“Record.dat”);
rename(“temp.dat”,”Record.dat”);

}

}

//END OF DELETE FUNCTION

//FUNCTION FOR CUSTOMER`S BILL

void hotel::bill(int r)
{

hotel h1;
ifstream f1;
f1.open(“record.dat”,ios::in|ios::binary);

if(!f1)
cout<“cannot>

else
{

f1.read((char*)&h1,sizeof (hotel));
while(f1)

{

f1.read((char*)&h1,sizeof(hotel));

}

if (h1.room_no == r)
{

if(h1.room_no>=1&&h1.room_no<>
cout<“your bill=””>

else if (h1.room_no>=35&&h1.room_no<>
cout<“your bill=”5000″”>

else
cout<“your bill=””>

}

else
{ cout<“room no.=”” not=””>

}

f1.close();
getch();

}

//END OF BILLING FUNCTION

//START OF MAIN PROGARM

int main()
{

hotel h;

system(“cls”);

cout<>
cout<“tt* hotel=”” management=”” project=””>
cout<>
cout<“ttdeveloped>
cout<“t g.=””>
cout<“ttttpress any=”” key=”” to=””>

getch();

h.main_menu();
return 0;
}

//END OF MAIN PROGRAM

 

 

 

Stressed over that homework?

Essay deadline breathing down your neck?

Let’s cut to the chase: Why struggle when you can ace it with zero hassle?

Whether it’s essays, research papers, or assignments — we’ve got you covered.

✅ Expert writers
✅ 100% original work
✅ No AI tools, just real pros

Stressed about your essay or homework? Get a top-quality custom essay NOW!!! Stop worrying. Start succeeding.

GradeEssays.com
We are GradeEssays.com, the best college essay writing service. We offer educational and research assistance to assist our customers in managing their academic work. At GradeEssays.com, we promise quality and 100% original essays written from scratch.
Contact Us

Enjoy 24/7 customer support for any queries or concerns you have.

Phone: +1 213 3772458

Email: support@gradeessays.com

© 2020 -2025 GradeEssays.com. All rights reserved.

WE HAVE A GIFT FOR YOU!

15% OFF 🎁

Get 15% OFF on your order with us

Scroll to Top