Question

In: Computer Science

In C++ All guests in ABC Hotel are either Elite members (meaning they get a free...

In C++

All guests in ABC Hotel are either Elite members (meaning they get a free breakfast) or Standard members (meaning they do not get a free breakfast). They collect points for every stay-Elite members earn 100 points for every day stayed in the hotel (so 2 days would be 200 points) and Standard member earns 50 points for every stay (so 3 days would be 140 points). Once 1000 points are reached, guests get a free stay. Guest details are kept in a file:

Sample input file1: Augustus, E-300,200, eggs//customer name, Membership level (E means elite), item ordered, ID number, points, breakfast choice

Sample input file2: Cyrus, S-100,30,x//customer name, Membership level(S means standard), item ordered, ID number, points, breakfast choice

1.The program should read in the number of points to get a free stay (1000) from the command line. It should continuously read in files of guests until the exit is entered (meaning the user can keep typing in file names-note that you can type in the same file name to open a previous guest).

2.Every time a file is opened, the program should ask how many days the guest is staying and award the appropriate number of points based on the membership level. The new point total should be saved in the file. If they are an elite member, they have the chance to change their breakfast choice.

3.When exiting, a file should be output with the number of guests that got a free stay (meaning their total points were 1000 or greater)

Sample output file:

Augustus had a free stay.

Jane had a free stay.

4.You should make a Hotel class and an abstract Person class. You should also make additional classes as necessary.

Solutions

Expert Solution

Solution:

Givendata:

All guests in ABC Hotel are either Elite members (meaning they get a free breakfast) or Standard members (meaning they do not get a free breakfast). They collect points for every stay-Elite members earn 100 points for every day stayed in the hotel (so 2 days would be 200 points) and Standard member earns 50 points for every stay (so 3 days would be 140 points). Once 1000 points are reached, guests get a free stay. Guest details are kept in a file:

Answer:

#pragma once
#include<string>
#include<iostream>
using namespace std;

class Person
{

public:

   string name;
   char memberShipLevel;
   int points;


   Person();
   Person(string n, char msl);

   void setName(string n);
   void setMemberShipLevel(char msl);


   string getName();
   char getMemberShipLevel();

   virtual void display() = 0;
};

#include "Person.h"

Person::Person()
{
   name = "";
}

Person::Person(string n, char msl)
{
   name = n;
   memberShipLevel = msl;
}

void Person::setName(string n)
{
   name = n;

}

void Person::setMemberShipLevel(char msl)
{
   memberShipLevel = msl;
}

string Person::getName()
{
   return name;
}

char Person::getMemberShipLevel()
{
   return memberShipLevel;
}

#include "Person.h"
#include<fstream>
#include<iostream>
using namespace std;

class Hotel :public Person
{
private:
   int totalMembers;
   string* files;
   string breakFast;

public:
   Hotel();
   Hotel(string n, char msl, int totalNumber);
   void setFilesOfmembers();
   void readFiles(string fileName);
   void setBreakFast(string Bf);

   string getBreakFast();

   void addMembers();

   void display();

};

#include "Hotel.h"
#include"Person.h"
#include<fstream>
#include<iostream>
using namespace std;


Hotel::Hotel() :Person()
{
   totalMembers = 4;
   files = new string[totalMembers];
}
Hotel::Hotel(string n, char msl, int totalNumber) : Person(n, msl)
{
   totalMembers = totalNumber;
   files = new string[totalMembers];

}


void Hotel::addMembers()
{
   fstream file;
   cout << "Enter total number of members" << endl;
   cin >> totalMembers;

   cout << "Total number of members are:" << totalMembers << endl;
   for (int i = 0; i < totalMembers; i++)
   {
       cout << "Enter the name of members for membership" << endl;
       cin >> files[i];
   }

}

void Hotel::setFilesOfmembers()
{
   fstream file;

   string guest;
   cout << "Enter the name of person You want to edit and view" << endl;
   cin >> guest;

   for (int i = 0; i < totalMembers; i++)
   {
       if (files[i] == guest)
       {
           readFiles(guest);
           display();
       }

       else
       {

           cout << "Member don't exist" << endl;
       }
   }

   file.open(guest, ios::out);

   if (!file)
   {
       cout << "Cannot open the file please try again" << endl;
   }
   else
   {
       cout << "FILE IS OPEND YOU CAN UPDATE THE INFORMATION" << endl;
       file << name;
       file << memberShipLevel;

       if (memberShipLevel == 'E')
       {
           int days;
           cout << "Enter number of days you want to stay" << endl;
           cin >> days;
           points = points + (days * 100);

           file << points;
           cout << "You can choose the breakfast choice as you are Elite member" << endl;
       }

       else
       {
           cout << "You are member of Standard level" << endl;

           int days;
           cout << "Enter the number of days you want to stay" << endl;
           cin >> days;
           points = points + (days * 50);
           file << points;


       }

       cout << "Sucessfully updated" << endl;
       file.close();
   }

  
  
  


}
void Hotel::readFiles(string fileName)
{
   fstream file;
   file.open(fileName, ios::in);

   if (!file)
   {
       cout << "You have entered a wrong persons file (No membership)" << endl;
   }

   else
   {
       cout << "FILE OPENED" << endl;

       while (!file.eof())
       {
           file >> name;
           file >> memberShipLevel;
           file >> points;
       }

       file.close();
   }


}

void Hotel::display()
{
   cout << "##INFORMATION OF GUEST##" << endl;
   cout << "NAME:" << name << endl;
   cout << "MEMBERSHIPLEVEL:" << memberShipLevel << endl;
   cout << "points:" << points << endl;
}

#include"Hotel.h"
#include"Person.h"
#include<iostream>
using namespace std;

int main()
{
   int choice;
   string guestName;
   Hotel obj;

   cout << "Enter 1)VIEW GUEST DATA AND EDIT 2)QUIT" << endl;
   cin >> choice;
   while (choice != 2)
   {
       cout << "Enter the name of Guest:" << endl;
       cin >> obj.name;
       cout << "Enter the memberShipLevel:" << endl;
       cin >> obj.memberShipLevel;

       obj.setFilesOfmembers();
       cout << "Enter 1)VIEW GUEST DATA AND EDIT 2)QUIT" << endl;
       cin >> choice;

   }
}

PLEASE GIVEME THUMBUP........


Related Solutions

The Wilton is an all-inclusive spa and hotel in the heart of Brooklyn and uses guests...
The Wilton is an all-inclusive spa and hotel in the heart of Brooklyn and uses guests as its measure of activity. During June, The Wilton budgeted for 2,000 guests, but it actually hosted 2,100 guests. The hotel used the following revenue and cost formulas in its budgeting, where q is the number of guests: Revenue: $62.90q Personnel expenses: $28,500 + $20.40q Food and beverage supplies: $1,400 + $9.90q Occupancy expenses: $8,200 + $3.30q Spa expenses: $4,000 + $0.40q The hotel...
Suppose that n guests all have an identical key to get into a conference, which is...
Suppose that n guests all have an identical key to get into a conference, which is given to the front desk of the venue. As they are leaving, the keys are given back in a random order. What is the probability that no guest gets back their original key?
Will a union behave differently if it wants to get all of its members employed instead...
Will a union behave differently if it wants to get all of its members employed instead of maximizing the total wage bill? Explain your answer. 250 word minimum requirement
C++ and there has to be a FUNCTION to get all the integers. Suppose there is...
C++ and there has to be a FUNCTION to get all the integers. Suppose there is a file called MidtermExam.txt that is full of integers. Write a program that complies with the following instructions: Write a function that you will later call in main. Your function is to read from the file all the integers and print to the screen the total of all the numbers in the file, and the average with 2 significant digits after the decimal point....
how do you get the sum of all elements in a stack in c++ ?
how do you get the sum of all elements in a stack in c++ ?
C# 1.Visual Studio .NET’s ___________ feature displays all the members in a class a.real-time error checking...
C# 1.Visual Studio .NET’s ___________ feature displays all the members in a class a.real-time error checking b.Quick Info c.outlined code d.Intellisense 2.An algorithm specifies the actions to be executed. True False 3.A(n) _________ occurs when an executed statement does not directly follow the previously executed statement in the written application. a.unordered execution b.transfer of control c.action state d.jump 4.The declarations and statements that compose the method definition are called the __________.    a.method body b.method header c.parameter list d.method name...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT