Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

code the following:GuestRoom contains the method CalculateBill(),which returns t

ID: 3558260 • Letter: C

Question

code the following:GuestRoom contains the method CalculateBill(),which returns the amount of the guest's bill.The bill is calculated as follows:the room rate (this is inherited from HotelRoom) multiplied by the number of days of the stay,multi- plied by the status (which represents the number of guests, is also inherited from HotelRoom). MeetingRoom also contains the method CalculateBill(), which returns the amount of the bill for renting the room for one day.The method cal- culates the bill as follows: the number of seats multiplied by 10.00, plus 500.00. Code a Display() method for each of GuestRoom and MeetingRoom, which displays in an appropriately formatted way the values of the instance variables of the class (including the inherited ones). Code a main() in which you create objects of each type, compute the bill for each object, and display each object's information. based off this original code

//define_class.cpp

            #include<iostream>

#include<string>

using namespace std;

//class declatration

class HotelRoom

{

private: string roomNumber;

                        int capacity;

                        int occupancy;

                        double rate;

public:

            //constructor with three parameters

            HotelRoom(string num, int count, double rent)

            {

                        roomNumber = num;

                        capacity = count;

                        rate = rent;

                        occupancy = 0;

            }

};

int main()

{

            //create instance of class

            HotelRoom room1("F103", 2, 800);

            //pause system for a while

            system("pause");

            return 0;

}

Explanation / Answer


#include <iostream>

#include <iomanip>

#include <cmath>


using namespace std;


class HotelRoom

{

protected:
   int k;
// room num
   int occup_stat;
   double daily_rt;


   // guest and daily rate will be added here in weeks ahead

public:

   HotelRoom(int i = 0, int occup = 0, double rate = 89.00); // one argument constructor for now
  
HotelRoom(const HotelRoom&); //copy constructor
  
~HotelRoom(); //deconstructor


};


HotelRoom::HotelRoom(int i, int occup, double rate) : k(i)

{

   cout <<endl;

   cout<< "HotelRoom room number: "
       <<k<< endl;

}


HotelRoom::HotelRoom(const HotelRoom& room_r) :k(room_r.k)

{

   cout<<endl;

   cout<<"(HotelRoom copy constructor executed)"<<endl;

}

HotelRoom::~HotelRoom()

{

   cout <<endl;
cout<<"(HotelRoom destructor executed)"<<endl;


}


class GuestRoom : public HotelRoom

{

protected:

   int capacity;

   int status;

   int days;

   double gbill;


public:

   GuestRoom(int c = 0, int s = 0, int d = 0);

   GuestRoom(const GuestRoom &);

   ~GuestRoom();

   double Calculate_Bill();

   void Display();


};


GuestRoom::GuestRoom(int c, int s, int d) : HotelRoom(k = 123), capacity(c), status(s), days(d)

{

   cout<<endl;

   cout<<"**GuestRoom constructor executed**"<<endl<<endl;
   cout <<"Maximum number of guest per room: "<<capacity<<endl;

       cout <<"Number of guest occupying room: "<<status<<endl;

       cout <<"Days that room is going to be occupied: "<<days<<endl;

}

GuestRoom::GuestRoom(const GuestRoom & hroom_r)
   :HotelRoom(hroom_r), capacity(hroom_r.capacity)

{

   cout<<endl;

   cout<<"**GuestRoom copy constructor executed**"
       <<endl;

}

GuestRoom::~GuestRoom()

{

   cout<<endl;

   cout<< "**GuestRoom destructor executed**"<<endl;

}

double GuestRoom::Calculate_Bill()
{

  
   gbill = occup_stat*days*daily_rt;


   return gbill;

}


void GuestRoom::Display()
{

  
   cout<< setprecision(2)
       <<setiosflags(ios::fixed)
       <<setiosflags(ios::showpoint);

   cout<<endl<<endl<<endl;

   cout<<"Daily Rate: "<<daily_rt<<endl;

   cout<<"Days Occupying: "<<days<<endl;

   cout<<"Occupancy Status: "<<occup_stat<<endl;

   cout<<"Guest bill: "<<gbill<<endl;

}


class MeetingRoom : public HotelRoom
{

protected:

   int seats;

   int status;

   double mbill;
  


public:

   MeetingRoom(int s = 0, int st = 0);

   MeetingRoom(const MeetingRoom &);

   ~MeetingRoom();

   double Calculate_Bill();

   void Display();


};


MeetingRoom::MeetingRoom(int s, int st) : HotelRoom(k = 123), seats(s), status(st)

{

   cout<<endl;

   cout<<"Constructor Executed "<<seats<<endl;


}


MeetingRoom::MeetingRoom(const MeetingRoom & mroom_r)
   :HotelRoom(mroom_r), seats(mroom_r.seats)

{

   cout<<endl;

   cout<<"~~MeetingRoom copy constructor executed~~"
       <<endl;

}

MeetingRoom::~MeetingRoom()

{

   cout<<endl;

   cout<< "~~MeetingRoom destructor executed~~"
       <<endl;

}

double MeetingRoom::Calculate_Bill()

{

      
mbill = seats * 10.00 + 500.00;
   return mbill;

}


void MeetingRoom::Display()

{

  
   cout<< setprecision(2)
       <<setiosflags(ios::fixed)
       <<setiosflags(ios::showpoint);


  
   cout<<endl<<endl<<"Meeting Room Information"<<endl<<endl;


   cout<<"Seats in the Meeting Room: "<<seats<<endl;

   cout<<"Status of the Meeting Room:"<<status<<endl;

   cout<<"Bill for renting the room: "<<mbill<<endl<<endl<<endl;

}

int main()

{

  

   HotelRoom room_object1(123, 4, 89.00);

   GuestRoom groom_object1(5,3,4);

   GuestRoom groom_object2 = groom_object1;

   MeetingRoom mroom_object1(100,1);

   MeetingRoom mroom_object2 = mroom_object1;

   cout <<endl;

mroom_object1.Calculate_Bill();

   mroom_object1.MeetingRoom::Display();

   groom_object1.Calculate_Bill();

   groom_object1.GuestRoom::Display();

   system("PAUSE");

   return 0;

}