NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io



//START OF THE PROGRAM FOR HOTEL MANAGEMENT

#include<iostream>
#include<conio.h>
#include<fstream>
#include<stdio.h>
#include<stdlib.h>
#include<dos.h>

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 dispay the main menu
void add(); //to book a room
void display(); //to display the customer record
void rooms(); //to display alloted 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<<"ntttt*************************";
cout<<"ntttt SIMPLE HOTEL MANAGEMENT ";
cout<<"ntttt * MAIN MENU *";
cout<<"ntttt*************************";
cout<<"nnnttt1.Book A Room";
cout<<"nttt2.Customer Records";
cout<<"nttt3.Rooms Allotted";
cout<<"nttt4.Edit Record";
cout<<"nttt5.Exit";
cout<<"nntttEnter 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<<"nntttWrong choice.....!!!";
cout<<"ntttPress any key to continue....!!";
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<<"n Enter Customer Detalis";
cout<<"n ----------------------";
cout<<"nn Room no: ";
cout<<"n Total no. of Rooms - 50";
cout<<"n Ordinary Rooms from 1 - 30";
cout<<"n Luxuary Rooms from 31 - 45";
cout<<"n Royal Rooms from 46 - 50";
cout <<"n Enter The Room no. you want to stay in :- "<<endl;
cin>>r;

flag=check(r);

if(flag)
cout<<"n Sorry..!!!Room is already booked";

else
{

room_no=r;
cout<<" Name: ";
cin>>name;
cout<<" Address: ";
cin>>address;
cout<<" Phone No: ";
cin>>phone;

fout.write((char*)this,sizeof(hotel));
cout<<"n Room is booked...!!!";

}

cout<<"n Press any key to continue.....!!";

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<<"n Enter room no. for a particular customer`s details :- "<<endl;
cin>>r;

while(!fin.eof())
{

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

system("cls");
cout<<"n Cusromer Details";
cout<<"n ----------------";
cout<<"nn Room no: "<<room_no;
cout<<"n Name: "<<name;
cout<<"n Address: "<<address;
cout<<"n Phone no: "<<phone;
flag=1;
break;

}

}

if(flag==0)
cout<<"n Sorry Room no. not found or vacant....!!";
cout<<"nn Press any key to continue....!!";

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<<"nttt List Of Rooms Allotted";
cout<<"nttt ----------------------";
cout<<"nn Room No.tNamettAddressttttPhone No.n";

while(!fin.eof())
{

fin.read((char*)this,sizeof(hotel));
cout<<"nn "<<room_no<<"tt"<<name;
cout<<"tt"<<address<<"tt"<<phone;

}

cout<<"nnntttPress any key to continue.....!!";
getch();
fin.close();

}


//FUNCTION FOR EDITING RECORDS AND FOR BILL


void hotel::edit()
{

system("cls");

int choice,r;
cout<<"n EDIT MENU";
cout<<"n ---------";
cout<<"nn 1.Modify Customer Record";
cout<<"n 2.Delete Customer Record";
cout<<"n 3. Bill Of Customer";
cout<<"n Enter your choice: ";

cin>>choice;
system("cls");

cout<<"n 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<<"n Wrong Choice.....!!";

}
cout<<"n Press any key to continue....!!!";

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<<"n Enter New Details";
cout<<"n -----------------";
cout<<"n Name: ";
cin>>name;
cout<<" Address: ";
cin>>address;
cout<<" Phone no: ";
cin>>phone;
file.seekg(pos);
file.write((char*)this,sizeof(hotel));
cout<<"n Record is modified....!!";
flag=1;
break;

}

}

if(flag==0)
cout<<"n Sorry Room no. not found or vacant...!!";
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.eof())
{

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

{

cout<<"n Name: "<<name;
cout<<"n Address: "<<address;
cout<<"n Pone No: "<<phone;
cout<<"nn 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<<"n Sorry room no. not found or vacant...!!";

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 open";

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<=30)
cout<<"your bill = 2000";

else if (h1.room_no>=35&&h1.room_no<=45)
cout<<"your bill = 5000" ;

else
cout<<"your bill = 7000";

}

else
{ cout<<"room no. not found";}

}

f1.close();
getch();

}

//END OF BILLING FUNCTION

//START OF MAIN PROGARM


int main()
{

hotel h;

system("cls");

cout<<"nttt****************************";
cout<<"nttt* HOTEL MANAGEMENT PROJECT *";
cout<<"nttt****************************";
cout<<"nnttDeveloped By:";
cout<<"t G. Rohit";
cout<<"nnnnnnntttttPress any key to continue....!!";

getch();

h.main_menu();
return 0;
}

//END OF MAIN PROGRAM
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.