Question: Can anyone help me to construct a coding flowchart for this program coding? Thank you! #include #include #include #include #include #include using namespace std; class
Can anyone help me to construct a coding flowchart for this program coding? Thank you!
#include
#include
#include
#include
#include
#include
using namespace std;
class hotel
{
int room_no;
char name[30];
char address[50];
char phone[10];
public:
void main_menu();
void add();
void display();
void rooms();
void edit();
int check(int);
void modify(int);
void delete_rec(int);
void bill(int);
};
void hotel::main_menu()
{
int choice;
while(choice!=5)
{
system("cls");
cout<<" \t\t\t\t*************************";
cout<<" \t\t\t\t SIMPLE HOTEL MANAGEMENT ";
cout<<" \t\t\t\t * MAIN MENU *";
cout<<" \t\t\t\t*************************";
cout<<" \t\t\t1.Book A Room";
cout<<" \t\t\t2.Customer Records";
cout<<" \t\t\t3.Rooms Allotted";
cout<<" \t\t\t4.Edit Record";
cout<<" \t\t\t5.Exit";
cout<<" \t\t\tEnter 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<<" \t\t\tWrong choice.....!!!";
cout<<" \t\t\tPress any key to continue....!!";
getch();
}
}
}
}
void hotel::add()
{
system("cls");
int r,flag;
ofstream fout("Record.dat",ios::app);
cout<<" Enter Customer Detalis";
cout<<" ----------------------";
cout<<" Room no: ";
cout<<" Total no. of Rooms - 50";
cout<<" Ordinary Rooms from 1 - 30";
cout<<" Luxuary Rooms from 31 - 45";
cout<<" Royal Rooms from 46 - 50";
cout <<" Enter The Room no. you want to stay in :- "< cin>>r; flag=check(r); if(flag) cout<<" 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<<" Room is booked...!!!"; } cout<<" Press any key to continue.....!!"; getch(); fout.close(); } 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 Details"; cout<<" ----------------"; cout<<" Room no: "< cout<<" Name: "< cout<<" Address: "< cout<<" Phone no: "< flag=1; break; } } if(flag==0) cout<<" Sorry Room no. not found or vacant....!!"; cout<<" Press any key to continue....!!"; getch(); fin.close(); } void hotel::rooms() { system("cls"); ifstream fin("Record.dat",ios::in); cout<<" \t\t\t List Of Rooms Allotted"; cout<<" \t\t\t ----------------------"; cout<<" Room No.\tName\t\tAddress\t\t\t\tPhone No. "; while(!fin.eof()) { fin.read((char*)this,sizeof(hotel)); cout<<" "< cout<<"\t\t"< } cout<<" \t\t\tPress any key to continue.....!!"; getch(); fin.close(); } void hotel::edit() { system("cls"); int choice,r; cout<<" EDIT MENU"; cout<<" ---------"; cout<<" 1.Modify Customer Record"; cout<<" 2.Delete Customer Record"; cout<<" 3. Bill Of Customer"; 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 Choice.....!!"; } cout<<" 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); } 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 Details"; 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 modified....!!"; flag=1; break; } } if(flag==0) cout<<" Sorry Room no. not found or vacant...!!"; file.close(); } 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<<" 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 vacant...!!"; else { remove("Record.dat"); rename("temp.dat","Record.dat"); } } 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(); } int main() { hotel h; system("cls"); cout<<" \t\t\t*****************************************"; cout<<" \t\t\t* OBJECT ORIENTED PROGRAMMING PROJECT *"; cout<<" \t\t\t*****************************************"; cout<<" \t\t\t\t\tPress any key to continue....!!"; getch(); h.main_menu(); return 0; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
