#include<iostream>
#include <fstream>
#include <string>
#include<cstring>
#include <stdio.h>
using namespace std;
struct listdec
{
string cus_name;
};
void screenheader() //function for the first page of this program
{
system("color 3e");
cout<<"\n :::::::::::::::::::::::::::::::::::::"
<<"\n :: @ @ ::"
<<"\n :: @ WELCOME TO @ ::"
<<"\n :: @ @ ::"
<<"\n :: @ Lovely Homestay @ ::"
<<"\n :: @ @ ::"
<<"\n :: [MENTION=430272 [MENTION=1280766 [MENTION=644141 [MENTION=644134 @
@@@@ [MENTION=430272 [MENTION=1280766 [MENTION=644141 [MENTION=644134 @
@@@@[/MENTION @
@@@ ::"
<<"\n :: ::"
<<"\n :::::::::::::::::::::::::::::::::::::\n\n"
<<"\n\t Near Bukit beruang,Jalan ???\n\t\t\tBukit Beruang,85000 segamat "
<<"\n\n Ph. No.:011-27243200\n\n";
system("Pause");
}
void intro() //the introduction of this program
{
system("color 0e");
cout<<"\n\n\n WELCOMES YOU.............."
<<"\n\n\n\tLovely Homestay is one of the newest home stay in Bukit Beruang. The\t\tLovely Home stay is equipped with with all the general amenities and \t\tfacilities that go along with memorable stay. Set amidst beautifully \t\tsmall landscaped gardens."
<<"\n\n\tThe Hotel have well furnished rooms along with rooms providing \t\t\tcomfortable environment. The hotel satisfies the needs of business \t\tas well as the leisure traveller. All the rooms at the home stay \t\tare furnished beautifully. All the rooms are fitted with amenities."
<<"\n\n AMENITIES .......\n"
<<"\n\t\t\t1. 100% Power backup.\n"
<<"\t\t\t2. Provide parking space.\n"
<<"\t\t\t3. Round the clock security.\n"
<<"\t\t\t4. Running hot and cold water.\n"
<<"\t\t\t5. Free internet service.\n"
<<"\t\t\t6. 24 hours room service.\n"
<<"\t\t\t7. Laundary service.\n"
<<"\nPress any character to continue:\n";
system("Pause");
}
void features() //menu
{
system("cls");
cout << "#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#\n"
<< "| Welcome to Lovely Homestay |\n"
<< "|====================================

\n"
<< "| Select: |\n"
<< "| 1 => Sp. Deluxe |\n"
<< "| 2 => Deluxe |\n"
<< "| 3 => General |\n"
<< "| 4 => Couple |\n"
<< "| 5 => C. Deluxe |\n"
<< "|-------------------------------------|\n"
<< "| 6 => Form |\n" //navigate user to the page they can key in details
<< "| 7 => Read |\n" //allow user to view profiles
<< "| 8 => Delete Records |\n" //allow user to delete profiles
<< "| 9 => Edit Records |\n" //allow user to edit profile
<< "|====================================

\n"
<< "| Q => Quit |\n"
<< "#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#\n";
cout << endl;
cout << "Choose => ";
}
void sp_delux() //details of Sp. Deluxe room
{
system("cls");
cout<<"\n Room number >>>1"
<<"\n Advance >>>750\n\n"
<<"\n FEATURES OF THIS ROOM "
<<"\n------------------------------------------------------------------"
<<"\n\n Room Type >>> Sp. Deluxe"
<<"\n\n Room charges >>> RM600 per day"
<<"\n\n 1. Bed >>> 2"
<<"\n\n 2.Capacity >>> 5"
<<"\n\n 3.Balcony available "
<<"\n------------------------------------------------------------------"
<<"\n ADDITIONAL FEATURES "
<<"\n------------------------------------------------------------------"
<<"\n\n 1.A/C available "
<<"\n\n 2.Geyser available"
<<"\n\n 3.TV available "
<<"\n------------------------------------------------------------------"
<<"\n NOTE :- Extra bed will cost RM8 per bed \n\n";
endl(cout);
system ("Pause");
}
void delux() //details of deluxe room
{
system("cls");
cout<<"\n Room number >>>2\n\n"
<<"\n Advance >>>500\n\n"
<<"\n FEATURES OF THIS ROOM "
<<"\n-------------------------------------------------------------------"
<<"\n\n Room Type >>> Deluxe "
<<"\n\n Room charges >>>RM500 per day"
<<"\n\n 1. Bed >>> 2"
<<"\n\n 2.Capacity >>> 5"
<<"\n-------------------------------------------------------------------"
<<"\n ADDITIONAL FEATURES "
<<"\n-------------------------------------------------------------------"
<<"\n\n 1.A/C available "
<<"\n\n 2.Geyser available"
<<"\n\n 3.TV available "
<<"\n-------------------------------------------------------------------"
<<"\n NOTE :- Extra bed will cost RM8 per bed \n\n";
system ("Pause");
}
void general() //details of general room
{
system("cls");
cout<<"\n Room number >>>3\n\n"
<<"\n Advance >>>400\n\n"
<<"\n FEATURES OF THIS ROOM "
<<"\n-------------------------------------------------------------------"
<<"\n\n Room Type >>> General "
<<"\n\n Room charges >>>RM500 per day"
<<"\n\n 1. Bed >>> 2"
<<"\n\n 2.Capacity >>> 5"
<<"\n-------------------------------------------------------------------"
<<"\n ADDITIONAL FEATURES "
<<"\n-------------------------------------------------------------------"
<<"\n\n 1.Geyser available "
<<"\n\n 2.TV available "
<<"\n-------------------------------------------------------------------"
<<"\n NOTE :- Extra bed will cost RM8 per bed \n\n";
endl(cout);
system ("Pause");
}
void couple() //details of Couple room
{
system("cls");
cout<<"\n Room number >>>4\n\n"
<<"\n Advance >>>500\n\n"
<<"\n FEATURES OF THIS ROOM "
<<"\n-------------------------------------------------------------------"
<<"\n\n Room Type >>> Couple "
<<"\n\n Room charges >>>RM300 per day"
<<"\n\n 1. Bed >>> 1"
<<"\n\n 2.Capacity >>> 2"
<<"\n-------------------------------------------------------------------"
<<"\n ADDITIONAL FEATURES "
<<"\n-------------------------------------------------------------------"
<<"\n\n 1.Geyser available"
<<"\n\n 2.TV available "
<<"\n-------------------------------------------------------------------"
<<"\n NOTE :- Extra bed will cost RM8 per bed \n\n";
endl(cout);
system ("Pause");
}
void c_delux() //details of c.deluxe room
{
system("cls");
cout<<"\n Room number >>>5\n\n"
<<"\n Advance >>>750\n\n"
<<"\n FEATURES OF THIS ROOM "
<<"\n-------------------------------------------------------------------"
<<"\n\n Room Type >>> Couple Deluxe "
<<"\n\n Room charges >>>RM450 per day"
<<"\n\n 1. Bed >>> 1"
<<"\n\n 2.Capacity >>> 2"
<<"\n-------------------------------------------------------------------"
<<"\n ADDITIONAL FEATURES "
<<"\n-------------------------------------------------------------------"
<<"\n\n 1.Small A/C available "
<<"\n\n 2.Geyser available"
<<"\n\n 3.TV available "
<<"\n-------------------------------------------------------------------"
<<"\n NOTE :- Extra bed will cost RM8 per bed \n\n";
endl(cout);
system ("Pause");
}
void b(int &days,int &numMember,int selection,char gender,char& name)
{
cout<<"Please enter how many days you want the room : ";
cin>> days;
bool retry;
do{
retry=false;
cout<<"Please enter how many member in your group : ";
cin>> numMember;
if((selection==1)||(selection==2)||(selection==3))///here also gt problem,it cant appear
{
if((numMember<1)||(numMember>5))
{
cout<<"\nMembers cannot be allocated this room.Allowed members are between 1-5.\n";
retry=true;
}
}
else if((selection==4)||(selection==5))///here also got problem , it cant appear
{
if((numMember<1)||(numMember>2))
{
cout<<"\nMembers cannot be allocated this room.Allowed members are between 1-2.\n";
retry=true;
}
}
}while(retry==true);
cout <<"\nHi ";
switch (gender)
{
case 'm' :cout <<"Mr. "<<name<< endl;///the name cannot appear,help!!!
break;
case 'f':cout <<"Ms. "<<name<<endl;
break;
default:cout<<name<<" ,Please enter your gender."<<endl;
break;
}
if (selection==1)//if-else statement for user's selection
cout<<"Your selection is Sp.Deluxe, and thank for the selection. ^^";
else if (selection==2)
cout<<"Your selection is Deluxe, and thank for the selection. ^^";
else if (selection==3)
cout<<"Your selection is General, and thank for the selection. ^^";
else if (selection==4)
cout<<"Your selection is Couple, and thank for the selection. ^^";
else if (selection==5)
cout<<"Your selection is C.Deluxe, and thank for the selection. ^^*";
}
void form(int days,int numMember,int &selection,char &gender, char &name) //form to allow user to key in their details
{
char FileName[100], Address[50],email[30], n,chse;
int Age,numcus;
string phoneNo, IC;
gender=toupper(gender);
do
{
system("CLS");
cout <<"------------------------------------------------------------------------------\n";
cout <<" DETAILS \n";
cout <<"------------------------------------------------------------------------------\n";
cout << "Thank for login our lovely homestay PROFILE"<<endl;
cout << "Please fill all Customer information below:";
cout << "\n\nCreate a PROFILE name: ";//profile name
cin >> FileName;
cout << "Enter Name : ";//user's name
cin >> name;
cout <<"Enter Gender(m/f) : ";//user's gender
cin >> gender;
cout << "Enter Age : ";//user's age
cin >> Age;
cout<<"Enter IC number : ";//user's IC
cin>> IC;
cout<<"Enter Address : ";//user's address
cin>> Address;
cout<<"Enter email addres : ";//user's email address
cin>> email;
cout<<"Enter phone number : ";//user's phone number
cin>> phoneNo;
cout<<"\nPlease enter the room number in which you want to stay (1-5) : ";//which room user choose to stay
cin>> selection;
{
if(selection<1||selection>5)//if-else statement for user's choice of room
{
cout<<"Wrong choice!! Please select a number between 1-5.\n";
cout<<"Do you want to continue? (y/n) : ";
cin>> chse ;
switch(chse) //switch-case statement when user key in the number which is out of range
{
case 'y': cout<<"\nPlease enter the room number in which you want to stay (1-5) : ";
cin>> selection;
b(days,numMember,selection,gender,name);
break;
case 'n':features();
break;
default:cout<<"Invalid choice";
break;
}
}
else
{
b(days,numMember,selection,gender,name);
}
}
int num_cus(0),new_num_cus(0);
ifstream list("LIST.txt",ios::in);
list>>num_cus;
new_num_cus=num_cus+1;
listdec name[new_num_cus];
if(num_cus>0)
{
for(int i=0;i<num_cus;i++)
{
list>>name[i].cus_name;
}
list.close();
ofstream inlist("LIST.txt",ios:

ut);
inlist<<new_num_cus<<endl;
for(int i=0;i<num_cus;i++)
{
inlist<<name[i].cus_name<<endl;
}
inlist<<FileName<<endl;
inlist.close();
}
else
{
ofstream inlist("LIST.txt",ios:

ut);
inlist<<new_num_cus<<endl<<FileName<<endl;
}
ofstream Customer(FileName, ios:

ut); //"key in the comment"
Customer << name << "\n" << gender << "\n" << Age << "\n" << IC << "\n" << Address << "\n" << email << "\n" << phoneNo << "\n" << selection << "\n" << days << "\n" <<numMember;
Customer.close();
cout << "\n\n";
cout<<"The data is saved.\n";
cout << "\n\n";
cout << "Do you want to create the information??? (y/n): ";
cin >> n;
}while(n=='y' || n=='Y');
}
void viewlist()
{
system("CLS");
int num_cus(0);
ifstream list("LIST.txt",ios:

ut);
list>>num_cus;
if(num_cus>0)
{
cout<<"The List of recorded data";
listdec name[num_cus];
for(int i=0;i<num_cus;i++)
{
list>>name[i].cus_name;
}
for(int i=0;i<num_cus;i++)
{
cout<<name[i].cus_name<<endl;
}
system("PAUSE");
}
else if(num_cus=0)
{
cout<<"There is no recorded data";
system("PAUSE");
}
}
void read() //allow user to view profile
{
char name[30],FileName[20], Address[50],email[30], n,gender,chse;
int Age,numMember,selection,days;
string phoneNo, IC;
ifstream Customer;
//loop for ??????
do
{
system("CLS");
cout << "OPEN CUSTOMER PROFILE"<<endl;
cout << "\nEnter the name of the file you want to open: ";
cin >> FileName;
ifstream Customer(FileName);
Customer>> name>> gender>> Age>> IC>> Address>> email>> phoneNo>> selection>> days>> numMember;
cout <<"\nEnter Name : "<<name;
cout <<"\nEnter Gender(m/f) : "<<gender;
cout <<"\nEnter Age : "<<Age;
cout <<"\nEnter IC number : "<<IC;
cout <<"\nEnter Address : "<<Address;
cout <<"\nEnter email addres : "<<email;
cout <<"\nEnter phone number : "<<phoneNo;
cout <<"\nPlease enter the room number in which you want to stay (1-5) : "<<selection;
cout <<"\nPlease enter how many days cust want the room : "<<days;
cout <<"\nPlease enter how many member in your group : "<<numMember;
cout << "\n\nDo you want to open another file? (y/n): ";
cin >> n;
}while(n=='y' || n=='Y');
}
void Delete() //function to delete record/profile
{
char Delete[101], n;
int num_cus(0);
string FileName;
ifstream listout("LIST.txt",ios::in);
listout>>num_cus;
system("CLS");
if(num_cus>0)
{
cout << "DELETE CUSTOMER PROFILE"<<endl;
listdec name[num_cus];
for(int i=0;i<num_cus;i++)
{
listout>>name[i].cus_name;
}
for(int i=0;i<num_cus;i++)
{
cout<<i+1<<") "<<name[i].cus_name<<endl;
}
cout << "Type the full filename that you want to delete:";
cin>>FileName;
for(int i=0;i<num_cus;i++)
{
if(FileName == name[i].cus_name)
{
for(int k=i;k<num_cus;k++)
name[i].cus_name = name[i+1].cus_name;
if (remove(FileName.c_str( )) !=0)
cout<<"Remove operation failed"<<endl;
else
cout<<FileName<<" data have been remove."<<endl;
}
}
num_cus=num_cus-1;
ofstream inlist("LIST.txt",ios:

ut);
inlist<<num_cus<<endl;
for(int i=0;i<num_cus;i++)
{inlist<<name[i].cus_name<<endl;}
}
else
{
cout<<"No record of "<<FileName<<"."<<endl;
}
system("Pause");
}
void edit() //functions to edit profile
{
char name[30],FileName[20], Address[50],email[30], n,gender,chse;
char Delete[101], cont;
int Age,numMember,selection,days;
string phoneNo, IC,Edit;
do //loop for editing profile
{
system("CLS");
cout << "EDIT CUSTOMER PROFILE"<<endl;
cout<<"\nPlease open the file that you want to edit: ";
cin>>FileName;
ifstream Customer(FileName);
Customer>> name>> gender>> Age>> IC>> Address>> email>> phoneNo>> selection>> days>> numMember;
cout <<"\nEnter Name : "<<name;
cout <<"\nEnter Gender(m/f) : "<<gender;
cout <<"\nEnter Age : "<<Age;
cout <<"\nEnter IC number : "<<IC;
cout <<"\nEnter Address : "<<Address;
cout <<"\nEnter email address : "<<email;
cout <<"\nEnter phone number : "<<phoneNo;
cout <<"\nPlease enter the room number in which you want to stay (1-5) : "<<selection;
cout <<"\nPlease enter how many days cust want the room : "<<days;
cout <<"\nPlease enter how many member in your group : "<<numMember;
cout << "\n\nWhich part do you want to edit? (1.Name /2.Gender /3.Age /4.IC /5.Address /6.Email /7.Phone Number /8****om Number /9.Days /10.Member )"<<endl<<endl;
cout << "Please insert a correct number (1/2/3/4/5/6/7/8/9/10): ";
cin >> Edit; //for users to key in which part of the profile they want to edit
if(Edit=="1") //if-else statement for choices user had key in
{
cout << "\nEnter Name: ";
cin >> name;
ofstream Customer(FileName, ios:

ut);
Customer << name << "\n" << gender << "\n" << Age << "\n" << IC << "\n" << Address << "\n" << email << "\n" << phoneNo << "\n" << selection << "\n" << days << "\n" <<numMember;
cout << "\n\nProcess succeed. Your '"<<name<<"' file has been updated."<<endl;
}
else if(Edit=="2")
{
cout << "\nEnter Gender(m/f): ";
cin >> gender;
ofstream Customer(FileName, ios:

ut);
Customer << name << "\n" << gender << "\n" << Age << "\n" << IC << "\n" << Address << "\n" << email << "\n" << phoneNo << "\n" << selection << "\n" << days << "\n" <<numMember;
cout << "\n\nProcess succeed. Your '"<<FileName<<"' file has been updated."<<endl;
}
else if(Edit=="3")
{
cout << "\nEnter Age: ";
cin >> Age;
ofstream Customer(FileName, ios:

ut);
Customer << name << "\n" << gender << "\n" << Age << "\n" << IC << "\n" << Address << "\n" << email << "\n" << phoneNo << "\n" << selection << "\n" << days << "\n" <<numMember;
}
else if(Edit=="4")
{
cout<<"\nEnter IC number: ";
cin>>IC;
ofstream Customer(FileName, ios:

ut);
Customer << name << "\n" << gender << "\n" << Age << "\n" << IC << "\n" << Address << "\n" << email << "\n" << phoneNo << "\n" << selection << "\n" << days << "\n" <<numMember;
cout << "\n\nProcess succeed. Your '"<<FileName<<"' file has been updated."<<endl;
}
else if(Edit=="5")
{
cout<<"\nEnter Address: ";
cin>>Address;
ofstream Customer(FileName, ios:

ut);
Customer << name << "\n" << gender << "\n" << Age << "\n" << IC << "\n" << Address << "\n" << email << "\n" << phoneNo << "\n" << selection << "\n" << days << "\n" <<numMember;
cout << "\n\nProcess succeed. Your '"<<FileName<<"' file has been updated."<<endl;
}
else if(Edit=="6")
{
cout<<"\nEnter email address : ";
cin>>email;
ofstream Customer(FileName, ios:

ut);
Customer << name << "\n" << gender << "\n" << Age << "\n" << IC << "\n" << Address << "\n" << email << "\n" << phoneNo << "\n" << selection << "\n" << days << "\n" <<numMember;
cout << "\n\nProcess succeed. Your '"<<FileName<<"' file has been updated."<<endl;
}
else if(Edit=="7")
{
cout<<"\nEnter Phone Number : ";
cin>>phoneNo;
ofstream Customer(FileName, ios:

ut);
Customer << name << "\n" << gender << "\n" << Age << "\n" << IC << "\n" << Address << "\n" << email << "\n" << phoneNo << "\n" << selection << "\n" << days << "\n" <<numMember;
cout << "\n\nProcess succeed. Your '"<<FileName<<"' file has been updated."<<endl;
}
else if(Edit=="8")
{
cout<<"\nPlease enter the room number in which you want to stay (1-5) : ";
cin>>selection;
ofstream Customer(FileName, ios:

ut);
Customer << name << "\n" << gender << "\n" << Age << "\n" << IC << "\n" << Address << "\n" << email << "\n" << phoneNo << "\n" << selection << "\n" << days << "\n" <<numMember;
cout << "\n\nProcess succeed. Your '"<<FileName<<"' file has been updated."<<endl;
}
else if(Edit=="9")
{
cout<<"\nPlease enter how many days cust want the room : ";
cin>>days;
ofstream Customer(FileName, ios:

ut);
Customer << name << "\n" << gender << "\n" << Age << "\n" << IC << "\n" << Address << "\n" << email << "\n" << phoneNo << "\n" << selection << "\n" << days << "\n" <<numMember;
cout << "\n\nProcess succeed. Your '"<<FileName<<"' file has been updated."<<endl;
}
else if(Edit=="10")
{
cout<<"\nPlease enter how many member in your group : ";
cin>>numMember;
ofstream Customer(FileName, ios:

ut);
Customer << name << "\n" << gender << "\n" << Age << "\n" << IC << "\n" << Address << "\n" << email << "\n" << phoneNo << "\n" << selection << "\n" << days << "\n" <<numMember;
cout << "\n\nProcess succeed. Your '"<<FileName<<"' file has been updated."<<endl;
}
else
{
cout<<"Your input is incorrect.";
cout << "\n\nProcess unsuccess. Your '"<<FileName<<"' file has not been updated."<<endl;
}
cout << "\n\n";
cout << "Do you want to edit another file? (y/n): ";
cin >> cont;
}while(cont=='y' || cont=='Y'); //when user wants to edit another file
}
int main() //main function
{
int days,numMember,selection;
char gender,name;
screenheader();
intro();
bool done=false;
char choose;
do{ //user key in their choice from the menu
features();
cin>>choose;
choose=toupper(choose);
switch(choose)
{
case '1':sp_delux();
break;
case '2':delux();
break;
case '3':general();
break;
case '4':couple();
break;
case '5':c_delux();
break;
case '6': form (days,numMember,selection,gender,name);
break;
case '7':read();
break;
case '8'

elete();
break;
case '9':edit();
break;
case 'Q' : done = true;
break;
default : cout << "Invalid choice!! Choose a number between 1-8" << endl; //when user enter out-of-range-number
system("pause");
break;
}
} while (!done);
cout << "Good Bye and have a nice day!" << endl;//when user choose to quit the program
system("PAUSE");
return 0;
}