Question: C++ Please read the question clearly and match the example output provided at the end. You will find files named Question1.cpp. It uses a House

C++

Please read the question clearly and match the example output provided at the end.

You will find files named Question1.cpp. It uses a House class which has not yet been defined. It is your task to define the class within the Question1.cpp file for use within the main block. You will need the following: 1. A default and parameterized constructor 2. Methods to get and set the number of bedrooms, bathrooms, parking spots, and the year the house was built. 3. Private members to store the state for each of the data items.

The output should match the example below. Example 1: How many bedrooms does your house have? 5 How many bathrooms does your house have? 2 How many cars fit in your garage? 1 What year was your house built? 2010 Your house has 2 more bedrooms Your house has 1 more bathrooms Your garage holds 2 fewer cars Your house was built 9 years after my own.

Question01.cpp

#include #include using namespace std;

/* * Definition of class House goes here */

/* * Remainder of file remains unchanged */ int main(void) { House myHouse(3, 1, 3, 2001); House yourHouse;

int input; cout << "How many bedrooms does your house have? "; cin >> input; yourHouse.setBeds(input);

cout << "How many bathrooms does your house have? "; cin >> input; yourHouse.setBaths(input);

cout << "How many cars fit in your garage? "; cin >> input; yourHouse.setCars(input);

cout << "What year was your house built? "; cin >> input; yourHouse.setYear(input);

int diff = myHouse.getBeds() - yourHouse.getBeds(); cout << "Your house has " << abs(diff) << (diff < 0 ? " more" : " fewer") << " bedrooms" << endl;

diff = myHouse.getBaths() - yourHouse.getBaths(); cout << "Your house has " << abs(diff) << (diff < 0 ? " more" : " fewer") << " bathrooms" << endl;

diff = myHouse.getCars() - yourHouse.getCars(); cout << "Your garage holds " << abs(diff) << (diff < 0 ? " more" : " fewer") << " cars" << endl;

diff = myHouse.getYear() - yourHouse.getYear(); cout << "Your house was built " << abs(diff) << " years" << (diff < 0 ? " after" : " before") << " my own." << endl;

return 0; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!