Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

 

 

Step by Step Solution

3.60 Rating (150 Votes )

There are 3 Steps involved in it

Step: 1

Answers Answer Here in this problem we have a simple hotel management program of C We have to draw a flowchart and block diagram of the program A flow... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Management Fundamentals Concepts Applications & Skill Development

Authors: Robert N. Lussier

6th edition

1483352269, 978-1483352268

More Books

Students also viewed these Accounting questions

Question

=+What are the outcomes?

Answered: 1 week ago

Question

CL I P COL Astro- L(1-cas0) Lsing *A=2 L sin(0/2)

Answered: 1 week ago

Question

Why is it important to take this course in management?

Answered: 1 week ago

Question

What is the IRS mileage rate for use of a car for business in 2013?

Answered: 1 week ago