HelpπŸ™ Need some pro c++ coder to help me solve my problem

Posts 1–3 of 3 Β· Page 1 of 1
πŸ™ Need some pro c++ coder to help me solve my problem
#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;
}
1.) You don't state your problem
2.) Don't wrap the code in [code][/ code] tags and give messy code.

You want help? Good luck.
Code:
#include<iostream>
#include <fstream>
#include <string>
#include<cstring>
#include <stdio.h>
using namespace std;

class billing
{
      public:
             int  room_cost, days,total;
             int selection , numbed;
             
             
             void calculate(int &numbed, int &room_cost, int &days, int &total);
             void show(int &total);
             void getinput(int &numbed, int &room_cost, int &days,int selection);
             
};


struct use
{
       char FileName[100], Address[50],email[30], n,chse;
       int Age;
       string phoneNo, IC;
       }; 
       
struct listdec
{
       string cus_name;
};

void billing::getinput(int &numbed, int &room_cost, int &days,int selection)
{
     switch(selection)
     {
                    case 1: room_cost=300;
                            cout<<"\nThe price for this room is RM"<<room_cost<<endl;
                            break; 
                    
                    case 2: room_cost=450;
                           cout<<"\nThe price for this room is RM"<<room_cost<<endl;
                           break;
                           
                    case 3: room_cost=500;
                            cout<<"\nThe price for this room is RM"<<room_cost<<endl;
                            break;
                            
                    case 4: room_cost=550;
                            cout<<"\nThe price for this room is RM"<<room_cost<<endl;
                            break;
                    
                    case 5: room_cost=600;
                            cout<<"\nThe price for this room is RM"<<room_cost<<endl;
                            break;
                    
                    default: cout<<"\nInvalid choice! Please re-enter the room value you wish to stay in.";
                             break;
                    
     }

}


void billing::calculate(int &numbed, int &room_cost, int &days, int &total)
{
    total = 0;
    total=(numbed*8)+(room_cost*days);
}

void billing::show(int &total)
{
     cout<<"\nThe total cost is RM "<<total<<endl;
}


void logo()
{
cout<<"                                   (   )                              \n"
    <<"       Welcome To                 (    )                              \n"
    <<"     Lovely Homestay               (    )                             \n"
    <<"                                  (    )                              \n"
    <<"                                    )  )                              \n"
    <<"                                   (  (                       /\\     \n"
    <<"                                    ( )                      /  \\  /\\    \n"
    <<"                            ________[_]________          /\\/     \\/  \\   \n"
    <<"               /\\          /\\        _____     \\       /   /\\/\\ /\\/   \\  \n"
    <<"              /  \\       //__\\       \\    /\\    \\   /\\/\\/              \\ \n"
    <<"     /\\     / /\\/\\\\     //____\\       \\__/  \\    \\/           \n"
    <<"    /  \\   /\\/     \\   //______\\       \\ |[]|     \\             \n"
    <<"   /    \\ /          //_________\\       \\|__|      \\              \n"
    <<"  /      \\          /XXXXXXXXXXXX\\                  \\              \n"
    <<"          \\        /__I_II  I__I__\\__________________\\             \n"
    <<"                      I_I|  I__I_____[]_|_[]_______ I                 \n"
    <<"                      I_II  I__I_____[]_|_[]_______ I                 \n"
    <<"                      I II__I  I     XXXXXXX        I                 \n"
    <<"                    ~~~~~'   '~~~~~~~~~~~~~~~~~~~~~~~~               \n\n";
    system("Pause");
}

void screenheader() //function for the first page of this program
{
   system("cls");
   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("cls");     
system("color 0e");
   cout<<"\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 => Create/Edit                    |\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 => Search                         |\n"
 	     << "|=====================================|\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 &total,int &days,int &numMember,int selection,char gender,string& name)
{
    billing pay;
    int numbed,room_cost;
    
     cout<<"Please enter how many days you want the room  : ";
     cin>> days;
     cout<<"How many extra beds do you want to add? If no please enter '0'. :";
     cin>>numbed;
     
     if (numbed>=0)
                 {
                               cout<<"Back to main menu.";
                               
                 }
                 else 
     cout<<"Invalid choice";
                        
     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. ^^";
            
            pay.getinput(numbed,room_cost,days,selection);
            pay.calculate(numbed,room_cost,days,total);
            pay.show(total);

}

   
void form(int days,int numMember,int &selection,char &gender, string& name) //form to allow user to key in their details
{
    billing pay;
    use r;
    int numcus;
    int numbed,room_cost,total;
    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 >>r.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 >> r.Age;

        cout<<"Enter IC number      : ";//user's IC
        cin>> r.IC;

        cout<<"Enter Address        : ";//user's address
        cin>> r.Address;
        
        cout<<"Enter email addres   : ";//user's email address
        cin>> r.email; 
        
        cout<<"Enter phone number   : ";//user's phone number
        cin>> r.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>> r.chse ;
            switch(r.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;
                          pay.getinput(numbed,room_cost,days,selection);
                          b(total,days,numMember,selection,gender,name);
                         
                     break;
                case 'n':features();
                     break;
                default:cout<<"Invalid choice";
                     break;
               } 
            }       
            else
            {
            b(total,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::out);
                 inlist<<new_num_cus<<endl;
                 for(int i=0;i<num_cus;i++)
                 {
                   inlist<<name[i].cus_name<<endl;
                 }
     inlist<<r.FileName<<endl;
     inlist.close();
     }
     
     else
     {
         ofstream inlist("LIST.txt",ios::out);
         inlist<<new_num_cus<<endl<<r.FileName<<endl;
     }
        ofstream Customer(r.FileName, ios::out); //"key in the comment"
        Customer << name << "\n" << gender << "\n" << r.Age << "\n" << r.IC << "\n" << r.Address << "\n" << r.email << "\n" << r.phoneNo << "\n" << selection << "\n" << days << "\n" <<numMember;
        Customer.close();
        cout << "\n\n";
        cout<<"The data is saved.\n";
        cout << "\n";
        cout << "Do you want to create the information??? (y/n): ";
        cin >> r.n;
        }while(r.n=='y' || r.n=='Y');

}


void viewlist()
{
     system("CLS");
     int num_cus(0);
     ifstream list("LIST.txt",ios::out);
     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
{
    use r; 
    char name[30],gender;
    int numMember,selection,days;
    ifstream Customer;
    //loop for ??????
	do
        {
        
        system("CLS");

        cout << "OPEN CUSTOMER PROFILE"<<endl;
	
        cout << "\nEnter the name of the file you want to open: ";
        cin >> r.FileName;
        ifstream student((r.FileName),ios::in);
        if(Customer)
        {
        Customer>> name>> gender>> r.Age>> r.IC>> r.Address>> r.email>> r.phoneNo>> selection>> days>> numMember;

        cout <<"\nEnter Name           : "<<name;
        cout <<"\nEnter Gender(m/f)    : "<<gender;
    	cout <<"\nEnter Age            : "<<r.Age;
	    cout <<"\nEnter IC number      : "<<r.IC;
    	cout <<"\nEnter Address        : "<<r.Address;
        cout <<"\nEnter email addres   : "<<r.email;
      	cout <<"\nEnter phone number   : "<<r.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\n";
        Customer.close();
        }
        else
     {
         cout<<"No such data\n";
        Customer.close();
     }
        cout << "\n\nDo you want to open another file? (y/n): ";
        cin >> r.n;
        }while(r.n=='y' || r.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)
                          { 
                                   if(num_cus==1)
                                   name[i].cus_name = " ";
                                   else if(i==num_cus-1)
                                   name[i].cus_name = " ";
                                   else
                                   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::out);
                                     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();
void form_edit()
{
     system("Cls");
     int days,numMember,selection;
     char gender;
     string name;
     char choice;
     cout <<"Create or Edit"<<endl;
     cout <<"1) Create "<<endl;
     cout <<"2) Edit   "<<endl;
     cin >> choice;
     
     switch(choice)
     {
        case '1':form(days,numMember,selection,gender,name);
        break;
        case '2':edit(); 
        break;
        default : cout<<"Invalide choice, try again..."<<endl;
        break;
                 system("pause");
                        
     }
}
      
void edit() //functions to edit profile
{
     use r;
     char name[30],gender;
	 char Delete[101], cont; 
	 int numMember,selection,days;
     string Edit;
      

        do //loop for editing profile
        {
        system("CLS");


        cout << "EDIT CUSTOMER PROFILE"<<endl;
        cout<<"\nPlease open the file that you want to edit: ";
        cin>>r.FileName;

        ifstream Customer(r.FileName);

        Customer>> name>> gender>> r.Age>> r.IC>> r.Address>> r.email>> r.phoneNo>> selection>> days>> numMember;

        cout <<"\nEnter Name           : "<<name;
        cout <<"\nEnter Gender(m/f)    : "<<gender;
    	cout <<"\nEnter Age            : "<<r.Age;
	    cout <<"\nEnter IC number      : "<<r.IC;
    	cout <<"\nEnter Address        : "<<r.Address;
        cout <<"\nEnter email address  : "<<r.email;
      	cout <<"\nEnter phone number   : "<<r.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? \n";
        cout<<"(1.Name /2.Gender /3.Age /4.IC /5.Address /6.Email /7.Phone Number \n";
        cout<<"/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(r.FileName, ios::out);
            Customer << name << "\n" << gender << "\n" << r.Age << "\n" << r.IC << "\n" << r.Address << "\n" << r.email << "\n" << r.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(r.FileName, ios::out);
           Customer << name << "\n" << gender << "\n" << r.Age << "\n" << r.IC << "\n" <<  r.Address << "\n" << r.email << "\n" << r.phoneNo << "\n" << selection << "\n" << days << "\n" <<numMember;
            cout << "\n\nProcess succeed. Your '"<<r.FileName<<"' file has been updated."<<endl;
        }

        else if(Edit=="3")
        {
            cout << "\nEnter Age: ";
            cin >> r.Age;

            ofstream Customer(r.FileName, ios::out);
           Customer << name << "\n" << gender << "\n" << r.Age << "\n" << r.IC << "\n" <<  r.Address << "\n" << r.email << "\n" << r.phoneNo << "\n" << selection << "\n" << days << "\n" <<numMember;
        }

        else if(Edit=="4")
        {
            cout<<"\nEnter IC number: ";
            cin>>r.IC;

            ofstream Customer(r.FileName, ios::out);
	    Customer << name << "\n" << gender << "\n" << r.Age << "\n" << r.IC << "\n" <<  r.Address << "\n" << r.email << "\n" << r.phoneNo << "\n" << selection << "\n" << days << "\n" <<numMember;
            cout << "\n\nProcess succeed. Your '"<<r.FileName<<"' file has been updated."<<endl;
        }

        else if(Edit=="5")
        {
            cout<<"\nEnter Address: ";
            cin>>r.Address;

            fstream Customer(r.FileName, ios::out);
	    Customer << name << "\n" << gender << "\n" << r.Age << "\n" << r.IC << "\n" <<  r.Address << "\n" << r.email << "\n" << r.phoneNo << "\n" << selection << "\n" << days << "\n" <<numMember;
            cout << "\n\nProcess succeed. Your '"<<r.FileName<<"' file has been updated."<<endl;
        }

        else if(Edit=="6")
        {
            cout<<"\nEnter email address : ";
            cin>>r.email;

            fstream Customer(r.FileName, ios::out);
	    Customer << name << "\n" << gender << "\n" << r.Age << "\n" << r.IC << "\n" <<  r.Address << "\n" << r.email << "\n" << r.phoneNo << "\n" << selection << "\n" << days << "\n" <<numMember;
            cout << "\n\nProcess succeed. Your '"<<r.FileName<<"' file has been updated."<<endl;
        }

        else if(Edit=="7")
        {
            cout<<"\nEnter Phone Number : ";
            cin>>r.phoneNo;

            fstream Customer(r.FileName, ios::out);
	    Customer << name << "\n" << gender << "\n" << r.Age << "\n" << r.IC << "\n" <<  r.Address << "\n" << r.email << "\n" << r.phoneNo << "\n" << selection << "\n" << days << "\n" <<numMember;
            cout << "\n\nProcess succeed. Your '"<<r.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;

            fstream Customer(r.FileName, ios::out);
	    Customer << name << "\n" << gender << "\n" << r.Age << "\n" << r.IC << "\n" <<  r.Address << "\n" << r.email << "\n" << r.phoneNo << "\n" << selection << "\n" << days << "\n" <<numMember;
            cout << "\n\nProcess succeed. Your '"<<r.FileName<<"' file has been updated."<<endl;
        }

        else if(Edit=="9")
        {
            cout<<"\nPlease enter how many days cust want the room : ";
            cin>>days;

            fstream Customer(r.FileName, ios::out);
	    Customer << name << "\n" << gender << "\n" << r.Age << "\n" << r.IC << "\n" <<  r.Address << "\n" << r.email << "\n" << r.phoneNo << "\n" << selection << "\n" << days << "\n" <<numMember;
            cout << "\n\nProcess succeed. Your '"<<r.FileName<<"' file has been updated."<<endl;
        }

	else if(Edit=="10")
        {
            cout<<"\nPlease enter how many member in your group : ";
            cin>>numMember;

            fstream Customer(r.FileName, ios::out);
	    Customer << name << "\n" << gender << "\n" << r.Age << "\n" << r.IC << "\n" <<  r.Address << "\n" << r.email << "\n" << r.phoneNo << "\n" << selection << "\n" << days << "\n" <<numMember;
            cout << "\n\nProcess succeed. Your '"<<r.FileName<<"' file has been updated."<<endl;
        }

        else
        {
            cout<<"Your input is incorrect.";
            cout << "\n\nProcess unsuccess. Your '"<<r.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

}

void search()
{
     
     system("CLS");
     
     string srch;
     bool test(true),out(false);
     int a=0;
     int num_cus;
     char agn;
     bool agns(true),agnw(true);
     
     do
     {system("CLS");
     ifstream list("LIST.txt",ios::out);
     list>>num_cus;
     if(num_cus>0)
     {
                  listdec name[num_cus];
                  for(int i=0;i<num_cus;i++)
                  {
                         getline(list,name[i].cus_name);
                  }

   do
    {
         test=true;
         a=0;
         cout<<"Search: ";
         getline(cin,srch);
         cin.clear();
         do
         {
              if((!isalpha(srch[a]))&&(srch[a]!=' '))
                  test = false;
                  a++;
         }while(srch[a]);
         if(!test)
         {
                  cout<<"Error, Please Make sure you key in ALPHABET ONLY(spece allowed)\n";
         }
    }while(!test);
                  
                  
                  for(int i=0;i<num_cus;i++)
                  {
                        unsigned pos = name[i].cus_name.find(srch);
                        if(pos==0)
                        {
                        cout<<name[i].cus_name<<endl;
                        out = true;
                        }
                  }  
                  if(!out)
                  cout<<"No data found\n";
     }
     do
     {
     cout<<"Do you want to search Another data?(y/n)";
     cin>>agn;
     cin.ignore();
     }while(agn=='y'||agn=='Y');
     }while(!agns);
     cout<<"Returning to main menu";
     
}


int main() //main function
{ 
    int days,numMember,selection;
    char gender;
    string name;
    logo();
    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_edit();
             break;
	         case '7':read();
	         break;
	         case '8':Delete();
	         break;
	         case '9':search();
	         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;
}

sry...i got problem at read , edit and search.
Posts 1–3 of 3 Β· Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us