Computer Science, asked by shabbirduaa, 1 year ago

#include
#include
#include
#include

using namespace std;

class Hotel
{
int room_number;
char name[30];
char address[50];
char phone[10];

public:
void add_customer()
{
system("cls");

cout<<"\nEnter The Room Number: ";
cin>>room_number;
cout<<"\nEnter The Customer's name: ";
cin.ignore();
cin.getline(name,30);
cout<<"\nEnter The Customer's address: ";
cin.ignore();
cin.getline(address,50);
cout<<"\nEnter The Customer's phone #: ";
cin.ignore();
cin.getline(phone,10);
cout<<"\t\t\n\nCustomer added Successfully...";
}
void show_customer()
{
system("cls");

cout<<"\n\tRoom Number: "< cout<<"\nCustomer'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,30);
cout<<"\nModify Customer's address: ";
cin.ignore();
cin.getline(address,50);
cout<<"\nModify Customer's phone #: ";
cin.ignore();
cin.getline(phone,10);
}

int getRoomNumber()
{
return room_number;
}
char* getName()
{
return name;
}
char* getAddress()
{
return address;
}

char* getPhone()
{
return phone;
}
void report()
{
cout< //cout<<"Room Number.\t"<<"Name\t\t"<<"Address\t\t"<<"Phone"< }
};

fstream fp;
Hotel h;

void save_customer()
{
system("cls");
int option;
fp.open("hotel.dat",ios::out|ios::app);
do
{
h.add_customer();
fp.write((char*)&h,sizeof(Hotel));
cout<<"\nPress 1 to add more customers.";
cout<<"\nPress 2 to return to main menu.\n";
cout<<"Option: ";
cin>>option;
}while(option == 1);

fp.close();
}


void display_a_customer(int r_number)
{
system("cls");
cout<<"\nCustomer DETAILS\n";
int check=0;
fp.open("hotel.dat",ios::in);
while(fp.read((char*)&h,sizeof(Hotel)))
{
if(h.getRoomNumber()==r_number)
{
h.show_customer();
check=1;
}
}
fp.close();
if(check==0)
cout<<"\n\nCustomer does not exist";
getch();
}

void modify_customer()
{
system("cls");
int r_number;
int found=0;
cout<<"\n\n\tMODIFY CUSTOMER'S RECORD";
cout<<"\n\n\tEnter The room number: ";
cin>>r_number;
fp.open("hotel.dat",ios::in|ios::out);
while(fp.read((char*)&h,sizeof(Hotel)) && found==0)
{
if(h.getRoomNumber()==r_number)
{
h.show_customer();
cout<<"\nEnter Customer's new information"< h.modify_customer_record();
int pos=-1*sizeof(h);
fp.seekp(pos,ios::cur);
fp.write((char*)&h,sizeof(Hotel));
cout<<"\n\n\t Record Updated Successfully...";
found=1;
}
}
fp.close();
if(found==0)
cout<<"\n\n Record Not Found ";
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\tCUSTOMER LIST\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 main_menu()
{
system("cls");

int option;

for(;;)
{

cout<<"\n\t\t@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@";
cout<<"\n\t\tPress 1 to BOOK A ROOM";
cout<<"\n\t\tPress 2 to DISPLAY ALL ROOMS ALLOTTED";
cout<<"\n\t\tPress 3 to DISPLAY SPECIFIC CUSTOMER RECORD";
cout<<"\n\t\tPress 4 to MODIFY CUSTOMER RECORD";
cout<<"\n\t\tPress 5 to Exit";
cout<<"\n\t\t@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n";
cout<<"\n\t\tOption: ";
cin>>option;
switch(option)
{
case 1:save_customer();
system("cls");
break;
case 2: display_all_customer();
system("cls");
break;
case 3:
int r_number;
system("cls");
cout<<"\n\n\tPlease Enter Customer's Room Number: ";
cin>>r_number;
display_a_customer(r_number);
break;
case 4:modify_customer();
system("cls");
break;

case 5: exit(0);
break;
default:cout<<"\a";
}
}
}

void intro()
{
system("cls");


system("cls");
cout<<"\t\t\t\t*\t*";
cout<<"\t\t\t\t*\t*";
cout<<"\t\t\t\t**\t**";
cout<<"\t\t\t\t**\t**";
cout<<"\t\t\t\t**\t**";
cout<<"\t\t\t\t***\t***";
cout<<"\t\t\t\t***\t***";
cout<<"\t\t\t\t***\t***";
cout<<"\t\t\t\t***\t***";
cout<<"\t\t\t\t**\t**";
cout<<"\t\t\t\t**\t**";
cout<<"\t\t\t\t**\t**";
cout<<"\t\t\t\t*\t*";
cout<<"\t\t\t\t*\t*";
}


int main(int argc, char *argv[])
{
intro();
main_menu();
return 0;
}


shabbirduaa: Please explain it to me

Answers

Answered by arohi4
0
what is this. what is ur question. I think it makes error in the program.

shabbirduaa: I want to understand this program int main(int argc, char *argv[])
{
intro();
shabbirduaa: specially this
arohi4: but I don't know dear
arohi4: sorry to say
Answered by komalchauhan1
0
what is ur question......
plz write ur question properly.....
hope u understand

shabbirduaa: How pointers are working in this program
shabbirduaa: what is the role of cin.get and cin.ignore
Similar questions