Question

IN C++ MUST INCLUDE HEADER FILE, IMPLEMENTATION FILE, AND DRIVER FILE. IN C++ Create a header...

IN C++ MUST INCLUDE HEADER FILE, IMPLEMENTATION FILE, AND DRIVER FILE.

IN C++

Create a header and implementation file to define an apartment class. Create a driver program to test the class, and create a make file to compile the driver program.

Create two files called apartment.h and appartmentImp.cpp along with creating a driver program named testApartment.cpp containing the main function.

Program Requirements:

• Class attributes should include integers for number of rooms, monthly rent, and square feet, as well as booleans for washer/dryer connections and pets allowed or not

• Driver file should create two apartment objects: onCampusApt and offCampusApt

• Prompt the user to enter all the attributes for both apartments.

• Display the attributes for both apartments with neat formatting

• Display whether the two apartments have identical values for all their attributes (testing for equality)

• Set the off-campus apartment to allow pets, have washer and dryer connections, and increase its square feet by 150

• Display the attributes for both again with neat formatting

• Display the price per square foot for both apartments

Your implementation file should provide the functionality for the class to accomplish all the program requirements.

Format your output so that the user of your program understands the values that were input and what was output for each calculation. Your program should have a user-friendly interface. Make sure your program is properly documented and good programming standards are followed.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

// Apartment.h

#ifndef ADD_H

#define ADD_H

class Apartment

{

private:

int num_rooms;

double monthly_rent;

double area;

bool washer_dryer_connection;

bool pet_allowed;

public:

Apartment(int a, double b, double c,bool d, bool e);

void setWasherDryerConnection(bool a);

void setPetAllowed(bool a);

void setArea(double a);

int getNumRooms();

double getMonthlyRent();

bool getWasherdryerConnection();

bool getPetAllowed();

double getArea();

bool equal(Apartment a);

void disp();

};

#endif


// Apartment.cpp
#include <iostream>
#include "Apartment.h"

using namespace std;


Apartment::Apartment(int a, double b, double c,bool d, bool e)
{
num_rooms = a;
monthly_rent = b;
area = c;
washer_dryer_connection = d;
pet_allowed = e;
}

void Apartment::setWasherDryerConnection(bool a)
{
washer_dryer_connection = a;
}
void Apartment::setPetAllowed(bool a)
{
pet_allowed = a;
}
void Apartment::setArea(double a)
{
area = a;
}

int Apartment::getNumRooms()
{
return num_rooms;
}

double Apartment::getMonthlyRent()
{
return monthly_rent;
}
bool Apartment::getWasherdryerConnection()
{
return washer_dryer_connection;
}
bool Apartment::getPetAllowed()
{
return pet_allowed;
}
  
double Apartment::getArea()
{
return area;
}

bool Apartment::equal(Apartment a)
{
if (num_rooms == a.getNumRooms() && monthly_rent == a.getMonthlyRent() && washer_dryer_connection == a.getWasherdryerConnection() &&
pet_allowed == a.getPetAllowed())

{
return true;
}
else
{
return false;
}
}


void Apartment::disp()
{
cout << "Number of rooms : " << num_rooms << endl;
cout << "Monthly Rent : $" << monthly_rent << endl;
cout << "Area(Sq feet) : " << area << endl;
if (washer_dryer_connection == false)
cout << "Washer/dryer connection : " << "No" << endl;
else
cout << "Washer/dryer connection : " << "Yes" << endl;
if (pet_allowed == false)
cout << "Pet Allowed : " << "No" << endl;
else
cout << "Pet Allowed : " << "Yes" << endl;

}


//ApartmentImp.cpp
#include <iostream>
#include "Apartment.h"
using namespace std;
int main(){


int num_rooms;
double monthly_rent;
double area;
bool washer_dryer_connection;
bool pet_allowed;

cout << "Enter number of rooms for onCampusApt :";   
cin >> num_rooms;
cout << "Enter monthly rent for onCampusApt :";   
cin >> monthly_rent;
cout << "Enter area for onCampusApt :";   
cin >> area;
cout << "Enter washer/dryer connection for onCampusApt (0-false/1-true) :";   
cin >> washer_dryer_connection;
cout << "Enter pet allowed for onCampusApt(0-false/1-true) :";   
cin >> pet_allowed;
Apartment onCampusApt(num_rooms,monthly_rent, area,washer_dryer_connection,pet_allowed);
cout << "OnCampusApt data is as follows:" << endl;
onCampusApt.disp();
cout<< endl;

cout << "Enter number of rooms for offCampusApt :";   
cin >> num_rooms;
cout << "Enter monthly rent for offCampusApt :";   
cin >> monthly_rent;
cout << "Enter area for offCampusApt :";   
cin >> area;
cout << "Enter washer/dryer connection for offCampusApt (0-false/1-true):";   
cin >> washer_dryer_connection;
cout << "Enter pet allowed for offCampusApt (0-false/1-true):";   
cin >> pet_allowed;
Apartment offCampusApt(num_rooms,monthly_rent, area,washer_dryer_connection,pet_allowed);
cout << "OffCampusApt data is as follows:" << endl;
offCampusApt.disp();

cout<< endl;
if (onCampusApt.equal(offCampusApt)){
cout << "Both are equal" << endl;
}
else {
cout << "Both are not equal" << endl;
}
offCampusApt.setWasherDryerConnection(true);
offCampusApt.setPetAllowed(true);
offCampusApt.setArea(offCampusApt.getArea() + 150);

return 0;
}

Add a comment
Know the answer?
Add Answer to:
IN C++ MUST INCLUDE HEADER FILE, IMPLEMENTATION FILE, AND DRIVER FILE. IN C++ Create a header...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • This is done in C++ Create an Employee class using a separate header file and implementation...

    This is done in C++ Create an Employee class using a separate header file and implementation file. Review your UML class diagram for the attributes and behaviors The calculatePay() method should return 0.0f. The toString() method should return the attribute values ("state of the object"). Create an Hourly class using a separate header file and implementation file. The Hourly class needs to inherit from the Employee class The calculatePay() method should return the pay based on the number of hours...

  • Create a C++ project Create an Employee class using a separate header file and implementation file....

    Create a C++ project Create an Employee class using a separate header file and implementation file. The calculatePay() method should return 0.0f. The toString() method should return the attribute values ("state of the object"). Create an Hourly class using a separate header file and implementation file. The Hourly class needs to inherit from the Employee class The calculatePay() method should return the pay based on the number of hours worked and the pay rate. Remember to calculate overtime! Create a...

  • Use C++ Create a Student header file (C++) . Declare the following operations in the file....

    Use C++ Create a Student header file (C++) . Declare the following operations in the file. setName() setMarks() setDateOfBirth() calculateGrade() - This method should compute and return grades based on the mark the student entered calculateAge() - This method should compute and return age using the DateOfBirth the user entered displayDetails() - This method should return a string displaying all the details of the user. Now write the implementation class for the header file. Now reuse these C++ Code in...

  • You should create a driver class that calls the implementation in a separate class. You should...

    You should create a driver class that calls the implementation in a separate class. You should not rely on static methods in the implementation class. Specific methods to be defined/implemented 1. Create and use each primitive type. 2. Create a constant that can be used as a sentinel. 3. Use an if to control program execution. 4. Use a for, while and do while loop in your program. 5. Create an array in your program, add values to it and...

  • Using C++ Create a header file that defines a class called Building. The variables: the width,...

    Using C++ Create a header file that defines a class called Building. The variables: the width, the length, and the height. There should be functions to set the width and height, to get the width and height, and to get the volume of the building. Note: each floor of the building is ten feet high. So, also get the number of floors in the building. Call the header file in a program, also called building. Do not accept invalid input....

  • C++ must use header files and implementation files as separate files. I’ll need a header file,...

    C++ must use header files and implementation files as separate files. I’ll need a header file, implementation file and the main program file at a minimum. Compress these files into one compressed file. Make sure you have adequate documentation. We like to manipulate some matrix operations. Design and implement a class named matrixMagic that can store a matrix of any size. 1. Overload the addition, subtraction, and multiplication operations. 2. Overload the extraction (>>) and insertion (<<) operators to read...

  • Please write a c++ header file, class implementation file and main file that does all of...

    Please write a c++ header file, class implementation file and main file that does all of the following and meets the requirements listed below. Also include a Output of your code as to show that your program works and functions properly. EXERCISING A DOUBLY-LINKED LIST CLASS This project consists of two parts, the second of which appears below. For the first part, write a class that implements an unordered list abstract data type using a doubly-linked list with pointers to...

  • I need a c++ visual basic program that will. Carpet Calculator. This problem starts with the...

    I need a c++ visual basic program that will. Carpet Calculator. This problem starts with the FeetInches class that is provided in the course Content area on the assignment page for this week. This program will show how classes will interact with each other as data members within another class. Modify the FeetInches class by overloading the following operators which should all return a bool. <= >= != Next add a copy constructor to the FeetInches class and a multiply...

  • I am working in c++. My program requires me to use a header file that is...

    I am working in c++. My program requires me to use a header file that is provided. I must use this header file and create 5 methods: 2 constructors, 2 accessors and this operation* on a 4x4 matrix. Matrix has 16 floating point values that must be entered by user. The Two operator functions: i*t; and t+i, multiply identity (i) matrix by user input value matrix and second function add identity (i) plus user input matrix transform. These two operations...

  • On Dev C++ Using the header file provided below "myClock.h", implement a C++ program that present...

    On Dev C++ Using the header file provided below "myClock.h", implement a C++ program that present the user with the following menu: "Press 1 to read the time." "Press 2 to enter a new time." "Press 3 to exit." -------------------------------------------------------------- Submit both file, myClock.h and your implementation .cpp myClock.h class myClock { public: myClock(); ~myClock(){}; void setTime(int, int, int); // Add the getter function prototype here . private: int hour; int minute; int second; };

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT