Question

In: Computer Science

Write a program for hotel booking system using C++ Program Requirement 1. You can write any...

Write a program for hotel booking system using C++

Program Requirement

1. You can write any program based on the title assigned.

2. The program must fulfill ALL the requirements below. The requirements listed below are the MINIMUM requirement. Your program may extend beyond the requirements if needed.

a) Create at least one (1) base class.

b) Create at least two (2) derived classes that inherit from the base class created in 2(a).

c) Create at least one (1) object for each class and one (1) array of objects for one of the class.

d) Create at least one (1) default constructor for every classes.

f) Apply dynamic memory allocation using keyword new and delete for any object or array of objects.

g) Create at least one (1) virtual function.

h) Write sufficient comments to explain your program.

(Note : Only a reasonable level of user input checking is needed. Assume that a user will input text and numbers in good faith. He/she will not purposely enter text into a number field and will not key in non-alphanumeric characters for all text fields.)

Solutions

Expert Solution

#include<iostream>
#include<fstream>
#include<windows.h>
#include<string>
using namespace std;

    struct Name              // structure for naming in program
    {
      char first[20];       //character arrays for the names used in program..
      char last[20];
      char date[20];
      int room;
      char cnic[20],mob[20];
    };
      
       //\\Functions prototyping//\/\\
            
       void vacant_rooms();                //for vacant rooms|
       void customer_reserve();           //for reservation  |
       void login();                     //for login         |
       void check();                    //for the guest history
       void user_total();                                //for user total on the time checkout
       void loading();                                   // for loading bar
       void help();                                     //for helping the user to operate the application
       void about();                                   //for about the program
       void del_resdata();                            // in order delete
       
//------------------------.>//


int main()
{
    system("color 34");
    int a;
    int choice;
    char again;
    char x[20];
    cout<<endl;
    cout<<"            *                                           *    "<<endl;   
    cout<<"          **                                            *   "<<endl;
    cout<<"   *** Welcome to the Hotel Reservation Application ****"<<endl;
    cout<<"          **                                             **  "<<endl;
    cout<<"            *                                           *   "<<endl;
    cout<<endl;                                                   
    
    Beep(2020,1100);                                                             // causes the computer to beep
    char l=219;                                                                  //for loading bar
    cout<<"Please wait while system is analyzing the data\n";
    for ( int i=0; i<10 ; i++)
    {
        Beep(2000,500);
        cout<<l; 
         }
    cout<<endl;
    cout<<"______________________________"<<endl; 
    cout<<"Please Enter Username and Password to proceed: "<<endl;
    cout<<endl;
    login();            //function calling of login
    cout<<"______________________________"<<endl;
    cout<<endl;
    do
    {
    cout<<"Welcome to the Main Menu "<<endl;
    cout<<endl;
    cout<<"Press 1 to Reserve a room. "<<endl; 
    cout<<endl;
    cout<<"Press 2 to see the vacant rooms. "<<endl;                        
    cout<<endl;
    cout<<"Press 3 to check out a room. "<<endl;
    cout<<endl;
    cout<<"Press 4 to see the history of reserved rooms. "<<endl;
    cout<<endl;
    cout<<"Press 5 to Delete the Reservation data. "<<endl;
    cout<<endl;
    cout<<"Press 6 to see about the Application. "<<endl;
    cout<<endl;
    cout<<"Press 7 for help. "<<endl;
    cout<<endl;
    cout<<"Press 0 to Exit application. "<<endl;
    cout<<"Enter Here_: ";
    cin>>a;
    cout<<"_____________________________________"<<endl;
    cout<<endl;
    switch(a)
    {
    cout<<"________________________________________"<<endl;
    case 0:
    break;
    case 1:
         cout<<"   *                                 *"<<endl;
         cout<<" ** Welcome to the Reservation Menu **"<<endl;
         cout<<"   *                                 *"<<endl;
         cout<<endl;
         cout<<endl;
         customer_reserve();     // function calling
         break;
         case 2:
         cout<<"   *                             *"<<endl;
         cout<<"  ** Welcome to the Vacant Rooms **"<<endl;
         cout<<"   *                             *"<<endl;
         cout<<endl;
         cout<<endl;
         vacant_rooms();    ///funtion calling
         break;
         case 3:
         cout<<" *                                 *"<<endl;
         cout<<"** Welcome to the User Total Menu  **"<<endl;
         cout<<" *                                 *"<<endl;
         cout<<endl;
         cout<<endl;
         user_total();    //function calling   
          break;          
         case 4:
         cout<<"               *                                 *"<<endl;
         cout<<"              ** Welcome to the History Menu     **"<<endl;
         cout<<"               *                                 *"<<endl;
         cout<<endl;
         cout<<endl;
                        
         check();    //function calling           
         break;           
         case 5:
         cout<<"        *                                                           *"<<endl;
         cout<<"    ** Welcome to Delete Reservation data function **"<<endl;
         cout<<"        *                                             *"<<endl;
         cout<<endl;
         cout<<endl;
         del_resdata();    //function calling
         break;         
         case 6:
         cout<<"      *                       *"<<endl;
         cout<<"   ** About the Application **"<<endl;
         cout<<"      *                       *"<<endl;
         cout<<endl;
         cout<<endl;
         about();     //function calling
         break;                     
         case 7:
         cout<<"     *                     *"<<endl;
         cout<<"   ** Welcome to the Help **"<<endl;
         cout<<"      *                     *"<<endl;
         cout<<endl;
         cout<<endl;
         help();    //function calling
         break;
  default:
                 cout<<"you have enter an invalid Choice "<<endl;
                 cout<<endl;
                 }
cout<<"Press 1 to go back into MAIN Menu or 0 to terminate the program: ";                    
cin>>again;
cout<<"___________________________________"<<endl;
cout<<endl;
}
while (again=='1');   
cout<<"Thankyou! for using Hotel Reservation application."<<endl;
cout<<"Have a nice day! "<<endl;
cout<<endl; 
cout<<endl;
cout<<"_________________________________________"<<endl;

     system ("pause");
     }
//....................................................................//
                        
//....................................................................//
void user_total()   //funtion definition  of function user_total
{
     int choice,days,total1;
    char AC,again;
    int c=1000;
    int single= 3000;
    int doubl=4500;
    int suit=6000;
    int time=24;
    int service=300;
    do
    {
    cout<<"Which kind of Room did the guest stayed in?  "<<endl;
    cout<<endl; 
               cout<<" 1.Single Rooms "<<endl;
               cout<<endl; 
               cout<<" 2.Double Rooms "<<endl;
               cout<<endl; 
               cout<<" 3.Suits "<<endl;
               cout<<endl; 
    
    cout<<"Select 1,2 or 3 . "<<endl;
    cout<<endl; 
    cout<<"Enter Your CHoice Here_: ";
    cin>>choice;
    cout<<"__________________________________"<<endl;
    switch(choice)
    {
    case 1:
         cout<<"You have Selected single room. "<<endl;
         cout<<endl;
         cout<<" For How many days did the guest stayed: ";
         cin>>days;
         cout<<endl;
         
              cout<<" Press Y for A/c and N for without A/c: ";
         cin>>AC;
         cout<<endl; 
        if (AC == 'Y' || AC == 'y')
{
         total1 =(c+single+time+service)*days;
          cout<<"Your Total Total bill + service tax = ("<<total1<<" Rs.)"<<endl;
          cout<<endl; 
          cout<<"______________________________"<<endl;
}       
         else if (AC == 'N' || AC == 'n')
 {        
         total1=(single+time+service) * days;
         cout<<"Your Total Total bill + service tax = ("<<total1<<" Rs.)"<<endl;
      cout<<endl; 
       cout<<"_______________________________"<<endl;
}      
         break;
         case 2:
         cout<<"You Have Selected Double room."<<endl;
          cout<<endl; 
         cout<<" For How many days did the guest stayed: ";
         cin>>days;
         cout<<endl;
        cout<<" Press Y for A/c and N for without A/c: ";
         cin>>AC;
         cout<<endl; 
         
        if (AC == 'Y' || AC == 'y')
{
         total1 =(c+doubl+time+service)*days;
          cout<<"Your Total Total bill + service tax = ("<<total1<<" Rs.)"<<endl;
cout<<endl; 
 cout<<"__________________________________"<<endl;
}       
         else if (AC == 'N' || AC == 'n')
 {        
         total1=(doubl+time+service) * days;
         cout<<"Your Total Total bill + service tax = ("<<total1<<" Rs.)"<<endl;
        cout<<endl; 
         cout<<"_______________________________________"<<endl;
}      
         break;
         case 3:
         cout<<"You Have Selected Suit. "<<endl;
         cout<<endl;
         cout<<" For How many days did the guest stayed: ";
         cin>>days;
         cout<<endl;      
         cout<<" Press Y for A/c and N for without A/c: ";
         cin>>AC;
         cout<<endl; 
        if (AC == 'Y' || AC == 'y')
{
         total1 =(c+suit+time+service)*days;
          cout<<"Your Total Total bill + service tax = ("<<total1<<" Rs.)"<<endl;
          cout<<endl;
           cout<<"_______________________________________"<<endl; 
}       
         else if (AC == 'N' || AC == 'n')
 {        
         total1=(suit+time+service) * days;
          cout<<"Your Total Total bill + service tax = ("<<total1<<" Rs.)"<<endl;
          
        cout<<endl; 
       cout<<"__________________________________________"<<endl;
}      
                  break;
                 default:
                 cout<<"you have enter an invalid Choice "<<endl;
                 cout<<endl; 
                 }
                 cout<<"Do you want to checkout for another room? (Y/N): ";
                 cin>>again;
                  cout<<"___________________________________"<<endl;
                 cout<<endl; 
    }
       while(again == 'y' || again == 'Y'); 

         }
        //....................................................................//
                        
      //....................................................................//
        
        void customer_reserve()    //function definition 
{

              Name guest;             // guest is the name structure
              Name guest2;
              char choicedo;       //for enter more data 

    do 
    { 
    ofstream file;                     
    file.open("User info input.txt",ios::out | ios::app);  //openning txt file 
if(!file)
{
         cout<<"Error: Cannot open file.\n";
         system("pause");
         }
         
    cout<<"Enter The Room # to be Reserved: ";
    cin>>guest.room;
    cin.ignore();                       // to skip the new line character
    cout<<endl;
    cout<<"Enter Guest's First Name: ";
    cin.getline(guest.first, 20);      
     cout<<endl;
    cout<<"Enter Guest's Last Name: ";
    cin.getline(guest.last, 20);
    cout<<endl;
    cout<<"Enter The Mobile no. of The Customer: +";
    cin.getline(guest.mob, 20);
    cout<<endl;
    cout<<"Enter The CNIC of The Customer: ";
    cin.getline(guest.cnic, 20);
    cout<<endl;
    cout<<"The Name of Manager in Charge: ";
    cin.getline(guest2.first, 20);
    cout<<endl;
    cout<<endl;
    cout<<"Date: ";
    cin.getline(guest.date, 20);
    cout<<endl;
    int a;                            ///for choice
    /////////////
    cout<<"Press 1 to Save or 2 to cancel: ";
    cout<<endl;
  cin>>a;
   if(a==1)
       {
    cout<<endl;
    file<<" Guests Info"<<endl;
    cout<<endl;
    file<<"------------------------------------------------------------"<<endl;
               file<<endl;
               file<<"              Reservation Data of Room no.: "<<guest.room<<endl;
               file<<endl;
               file<<"The Name of the Guest is: "<<guest.first<<" "<<guest.last<<endl;
               file<<endl;
               file<<"Mobile No.: +"<<guest.mob<<endl;
               file<<endl;
               file<<"CNIC No.: "<<guest.cnic<<endl;
               file<<endl;
               file<<"Name of Manager in Charge is: "<<guest2.first<<endl;
               file<<endl;
               file<<"Date: "<<guest.date<<endl;
               file<<endl;
    file<<endl;  
    file<<"------------------------------------------------------------"<<endl;
    file.close(); 
    cout<<"Record Saved..."<<endl;
    cout<<"__________________________________"<<endl;
    cout<<endl;
}         
         else
 {        
         cout<<"Record Was Not Saved"<<endl;
          cout<<"____________________________________"<<endl;
         cout<<endl;
        }
         cout<<"Enter Y To input an other data or Enter N to Exit: ";
         cin>>choicedo;
         cout<<"_____________________________________"<<endl;
         cout<<endl;
         }
         while (choicedo=='y' || choicedo=='Y');  //to enter more data
 //}          
}
         
         
         //....................................................................//
                        
//....................................................................//

void vacant_rooms()    //function definition
{
     ifstream infile,infile2,infile3;           //ifstream for file reading
    char name[89],name2[89],name3[89],name4[100];
    int see;
    char again;
    do
    {
    cout<<"Press 1 to see the list of Single Rooms. "<<endl;
    cout<<endl;
    cout<<"Press 2 to See the list of Double Rooms. "<<endl;
    cout<<endl;
    cout<<"Press 3 to See the list of Suits. "<<endl;
    cout<<endl;
    cout<<"Enter Your Choice Here_: ";
    cin>>see;
    cout<<endl;
    switch(see)
    {
    case 1:
    infile.open("infoVS.txt",ios::in);
if (!infile)
{
            cout<<"File not found."<<endl;
            exit(1);
            }
            else
            {
while(!infile.eof())
{
infile>>name>>name2>>name3;
    cout<<name<<" "<<name2<<" "<<name3<<endl;
   

    cout<<endl;
}
    infile.close();        //closing the file
                           } 
break;
case 2:

           infile2.open("infoVD.txt",ios::in);
   if(!infile2)
   {
               cout<<"File not found."<<endl;
               exit(1);
               }
               else
               {
   while(!infile2.eof())
       {  
infile2>>name>>name2>>name3;
cout<<name<<" "<<name2<<" "<<name3<<endl;
cout<<endl;
}
     infile2.close();
}
break;

case 3:

           infile3.open("infoVSu.txt",ios::in);    // opening file
 if(!infile3)
 {
  cout<<"File not found."<<endl;
  exit(1);
}
else
{
      
     while(!infile3.eof())
     {
      infile3>>name>>name2>>name3;
    cout<<name<<" "<<name2<<" "<<name3<<endl;
    cout<<endl;
}


     infile3.close();
}
     break;
     
     default:
             cout<<"You have entered an invalid choice"<<endl;
             cout<<endl;
             }
     cout<<"Do you want to see the List of vacant Rooms again? (Y/N): ";
     cin>>again;
     cout<<endl;
}while (again=='Y' || again=='y');
     cout<<endl;  
}

//....................................................................//
                        
//....................................................................//

void login()                      //function calling
{
 char log_file1[20], pass_file1[20];
    char log_file2[20], pass_file2[20];
    
 ifstream username,passward;
    username.open("user.txt");
 if(!username)
 {
                 cout<<"File Not Found....";
                 exit(1);
                 }
    passward.open("pass.txt");
    if(!passward)
 {
                 cout<<"File Not Found....";
                 exit(1);
                 }
         // reading username from file 2....        
  username.getline(log_file2, 50);
  while (strcmp(log_file1, log_file2))
  {
   cout<<"\nUser Name: ";
          cin.getline(log_file1, 50);
   if (strcmp(log_file1, log_file2) ==0)  //comparing the username
          break;
             
   else
   Beep(3320,400);
          cout<<"\nInvalid Username.\n";   
  }
  
  passward.getline(pass_file2, 50); // reading password from file 2
  while (strcmp(pass_file1, pass_file2) !=0)
  {
   cout<<"\nPassword: ";
   cin.getline(pass_file1, 50);
   if (strcmp(pass_file1, pass_file2) ==0)  //comparing the password
   cout<<"\n\t  Logged in Successfully!!!" <<endl<<endl<<endl;
   else
         Beep(3320,400);
          cout<<"\nInvalid Password\n";
  }
  username.close();          // closing the file
  passward.close();             // closing the file
}
//....................................................................//
                        //function definition ended
//....................................................................//

void check()    /// function definition
{
    
    char doagain;
    do
    {
     fstream data;
     char word[100];
     
     data.open("User info input.txt",ios::in);
     cout<<endl;
     if(!data)
     {
              cout<<"File not found."<<endl;
              exit(1);
              }
     else
     {
     while(!data.eof())
     {
   
         data.getline(word,100);
         cout<<word<<"\n";
         data.getline(word,100);
         cout<<word<<"\n";
         data.getline(word,100);   
         cout<<word<<"\n";
         data.getline(word,100);
         cout<<word<<"\n";
         }         
         data.close();
         cout<<"Press Y to see the history again or N to cancel.";
         cin>>doagain;
         cout<<"___________________________________"<<endl;
         cout<<endl;
         }
}
while (doagain=='y' || doagain=='Y');
}                 

//....................................................................//

void del_resdata()    ///function definition
{
   char again;
   int x;
   fstream deletefile;
  do
  {
    cout<<"Enter 1 to delete the reservation data or 2 to cancel: "; 
    cin>>x;
    cout<<endl;
    if (x==1)
    {
    deletefile.open("User info input.txt", ios::out | ios::trunc); //trunc for delete data 
    if(!deletefile)
    {
    cout<<"File not found."<<endl;
    exit(1);
    }
    else
    {
    cout<<"Data has been deleted from the file."<<endl;
    cout<<endl;
    }
}
else
{
cout<<"Data not deleted.."<<endl;
cout<<endl;
}
cout<<"Enter Y to run this function again or N to cancel: ";
cin>>again;
cout<<endl;
cout<<"_____________________________________________"<<endl;
}
while (again=='Y' || again=='y');
deletefile.close();
}
void about()
{
             cout<<"About the Application"<<endl;
             cout<<"______________________________________"<<endl;
             cout<<endl;
             cout<<"This application is specially made for Hotel Reservation to "<<endl;
             cout<<"Organize data and to perform tasks, which can be useful for "<<endl;
             cout<<"Reservation.It can recored and analyze data of guests.With "<<endl;
             cout<<"this application you can not only see the past history of "<<endl;
             cout<<"guests,stayed in the hotel but you can also reserve rooms "<<endl;
             cout<<"for the future as well.You can also calculate the bill of "<<endl;
             cout<<"guests on the basis of time they have spent in the hotel  "<<endl;
             cout<<endl;
             cout<<"This application is user friendly and one can easily use "<<endl;
             cout<<"this application.Thank you!"<<endl;
             cout<<endl;
                         cout<<"______________________________________________"<<endl;
}
                  
void help()
{
             cout<<endl;
             cout<<"This application will work according to the desired entries by "<<endl;
             cout<<"the user.The reservation data will be stored in a text file present "<<endl;
             cout<<"where the application is located.If the text file is not present "<<endl;
             cout<<"the program will not work properly and will terminate.Follow the  "<<endl;
             cout<<"displayed on the screen.Select the proper option to operate "<<endl;
             cout<<"instructions the application.Goodluck! "<<endl;
             cout<<endl;
}

Related Solutions

Can you solve this C program by using Function? Q1. Write a C program to ring...
Can you solve this C program by using Function? Q1. Write a C program to ring the computer bell at any number of times you specify. Use the system clock as a delay, you need to include the time header file.
Write a C or C++ program using the fork() system call function. You will need to...
Write a C or C++ program using the fork() system call function. You will need to create 3 processes – each process will perform a simple task. Firstly, create an integer "counter" initialized to a random value between 1 and 100. Print this number to the console. This can be done by: Including the stdio.h and stdlib.h libraries Using the rand() function to generate your randomly generated number The main thread consists of the parent process. Your job is to...
Program this in C thank you PROBLEM DESCRIPTION: Write a program to implement the following requirement:...
Program this in C thank you PROBLEM DESCRIPTION: Write a program to implement the following requirement: The program will read from standard input two things - a string str1 on the first line of stdin (this string may be an empty string) - a string str2 on the second line of stdin (this string may be an empty string) Note that stdin does not end with '\n'. The program will output a string that is the concatenation of string str1...
using c++ You have been contracted to build a hotel reservation system. This is the system...
using c++ You have been contracted to build a hotel reservation system. This is the system that hotel desk clerks will use to take desk reservations. Assumptions: This is acting as though the only reservations taken are at the desk. All reservations are for one night. The hotel is empty when you start the program. First, this program will give the full inventory of rooms in the hotel. Total rooms: 122 There are four types of rooms with these prices:...
Using Loops for the Hotel Occupancy calculator. You will write a program that calculates the occupancy...
Using Loops for the Hotel Occupancy calculator. You will write a program that calculates the occupancy of a hotel. Rules: 1# The hotel must have more than 2 floors and less than or equal 5 floors. 2# Each floor in the hotel can have a different number of rooms on the floor. 3# You must set the number of occupied rooms. Again, there must less rooms occupied than the number of rooms. 4# Using the total number of rooms and...
Can you write a program for the card game WAR using linked lists in c++!
Can you write a program for the card game WAR using linked lists in c++!
Write a program using C language that -ask the user to enter their name or any...
Write a program using C language that -ask the user to enter their name or any other string (must be able to handle multiple word strings) - capture the epoch time in seconds and the corresponding nanoseconds - ask the user to type in again what they entered previously - capture the epoch time in seconds and the corresponding nanoseconds -perform the appropriate mathematical calculations to see how long it took in seconds and nanoseconds (should show to 9 decimal...
Hotel Occupancy C++ Only Program Description Write a program that calculates the occupancy rate for a...
Hotel Occupancy C++ Only Program Description Write a program that calculates the occupancy rate for a hotel. The program should read its data from a file named "hotel.dat". The first line of this file will be a single integer specifying the number of floors in the hotel. Each of the remaining (N) lines will have two integers; the number of rooms on that floor and the number of occupied rooms on that floor. Your program should display the following: How...
Can you write a program for snakes and ladder board game using linked lists in c++
Can you write a program for snakes and ladder board game using linked lists in c++
Write a C++ program that will be an information system for Oregon State University using classes...
Write a C++ program that will be an information system for Oregon State University using classes as well as demonstrating a basic understanding of inheritance and polymorphism. You will create a representation of an Oregon State University information system that will contain information about the university. The university will contain a name of the university, n number of buildings, and m number of people. People can be either a student or an instructor. Every person will have a name and...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT