Write a program in which you declare a class HotelRoom. The class has the fol- l
ID: 3555849 • Letter: W
Question
Write a program in which you declare a class HotelRoom. The class has the fol-
lowing private instance variables: the room number (a string), the room capacity
(an integer representing the maximum number of people the room can accom-
modate), the occupancy status (an integer, 0 if the room is not occupied, other-
wise the number of occupants in the room),and the daily rate (a double).Include
a three-argument constructor that sets the room number to its first argument,the
room capacity to the second argument, the room rate to the third argument, and
that sets the room occupancy status to 0.Compile and test the program.Note:We
will continue this exercise in the next section.
Explanation / Answer
Dear,
Haven't specified language you are looking for giving you in c++.
#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;
}
Hope this will help you!!
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.