#include
#include
#include
#include
using namespace std;
class Hotel
{
int room_number;
char name[40];
char address[60];
char phone[15];
public:
void add_customer()
{
system("cls");
cout<<"Enter the room number: ";
cin>>room_number;
cout<<"Enter Customer's name: ";
cin.ignore();
cin.getline(name,40);
cout<<"Enter Customer's address: ";
cin.getline(address,60);
cout<<"Enter The Customer's phone no. : ";
cin.ignore();
cin.getline(phone,15);
cout<
}
void show_customer()
{
system("cls");
cout<<"\nCustomer's Information"<
cout<<"Room Number: "<
cout<<"Customer's Name: "<
cout<<"\nCustomer's Address: "<
cout<<"\nCustomer's Phone: "<
}
void modify_customer_record()
{
system("cls");
cout<<"\nRoom number : "<
cout<<"\nModify Customer's Name : ";
cin.ignore();
cin.getline(name,40);
cout<<"\nModify Customer's address: ";
cin.ignore();
cin.getline(address,60);
cout<<"\nModify Customer's phone no. : ";
cin.ignore();
cin.getline(phone,15);
}
int getRoomNumber()
{
return room_number;
}
char* getName()
{
return name;
}
char* getAddress()
{
return address;
}
char* getPhone()
{
return phone;
}
void report()
{
cout<
}
};
fstream fp;
Hotel H;
void save_customer()
{
system("cls");
int choice;
fp.open("hotel.dat",ios::out|ios::app);
do
{
H.add_customer();
fp.write((char*)&H,sizeof(Hotel));
cout<<"Press 1 to add more customers."<
cout<<"Press 2 to return to main menu."<
cout<<"Choice: ";
cin>>choice;
}
while(choice == 1);
fp.close();
}
void display_a_customer(int roomnumber)
{
system("cls");
cout<<"\nCustomer's Information\n";
int check=0;
fp.open("hotel.dat",ios::in);
while(fp.read((char*)&H,sizeof(Hotel)))
{
if(H.getRoomNumber()==roomnumber)
{
H.show_customer();
check=1;
}
}
fp.close();
if(check==0)
cout<<"\nSorry..!!! Customer does not exist";
getch();
}
void modify_customer()
{
system("cls");
int roomnumber;
int found=0;
cout<<"\nMODIFY CUSTOMER'S RECORD";
cout<<"\n\tEnter The room number: ";
cin>>roomnumber;
fp.open("hotel.dat",ios::in|ios::out);
while(fp.read((char*)&H,sizeof(Hotel)) && found==0)
{
if(H.getRoomNumber()==roomnumber)
{
H.show_customer();
cout<<"\nModify customer's information which you want.."<
H.modify_customer_record();
int pos=-1*sizeof(H);
fp.seekp(pos,ios::cur);
fp.write((char*)&H,sizeof(Hotel));
cout<<"\n\n\t Information updated successfully...";
found=1;
}
}
fp.close();
if(found==0)
cout<<"\nSorry..!!! Information not found for this room number.. ";
getch();
}
void display_all_customer()
{
system("cls");
fp.open("hotel.dat",ios::in);
if(!fp)
{
cout<<"ERROR!!! FILE COULD NOT BE OPEN ";
getch();
return;
}
cout<<"\n\n\t\tCUSTOMERS RECORD \n\n";
cout<<"*******************************************************************\n";
cout<<"Room number\t"<<"Name\t\t"<<"Address\t\t"<<"Phone"<
cout<<"*******************************************************************\n";
while(fp.read((char*)&H,sizeof(Hotel)))
{
H.report();
}
fp.close();
getch();
}
void frontpage()
{
system("cls");
int choice;
while(1)
{
cout<<"\t\t\t\t***********************************"<
cout<<"\t\t\t\t** Welcome to Grand Palm Hotel **"<
cout<<"\t\t\t\t***********************************"<
cout<
cout<<"\t^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*"<
cout<<"\tPress 1 to BOOK A ROOM"<
cout<<"\tPress 2 to DISPLAY ALL ROOMS ALLOTTED"<
cout<<"\tPress 3 to DISPLAY SPECIFIC CUSTOMER RECORD"<
cout<<"\tPress 4 to MODIFY CUSTOMER RECORD"<
cout<<"\tPress 5 to Exit"<
cout<<"\t^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*"<
cout<<"\n\t\tEnter your choice here: ";
cin>>choice;
switch(choice)
{
case 1:save_customer();
system("cls");
break;
case 2: display_all_customer();
system("cls");
break;
case 3:
int roomnumber;
system("cls");
cout<<"\n\n\tPlease Enter Customer's Room Number: ";
cin>>roomnumber;
display_a_customer(roomnumber);
break;
case 4:modify_customer();
system("cls");
break;
case 5: exit(0);
break;
default:cout<<"\n\nInvalid choice entered...\n"<
{
exit(0);
}
break;
}
}
}
int main()
{
frontpage();
return 0;
}
shabbirduaa:
i want flowchart of this program
Answers
Answered by
0
this program will not run as u have not included the header files
Similar questions