Answered Essay: C++ Create two files called apartment.h and appartmentImp.cpp to your directory

C++ Create two files called apartment.h and appartmentImp.cpp to your directory, Create 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.

Expert Answer

 

Note : Could you please check the output .If you required any changes Just intimate.I will modify it.Thank You.

________________

Appartment.h

#ifndef APPARTMENT
#define APPARTMENT_H

class Appartment
{
public:
Appartment();
void setNoOfRooms(int noOfRooms);
void setMonthlyRent(double monthlyRent);
void setSqFeet(int sqFeet);
void setIsWasherAllowed(bool washer);
void setIsDryerAllowed(bool dryer);
void setIsPetsAllowed(bool pets);

int getNoOfRooms();
double getMonthlyRent();
int getSqFeet();
bool getIsWasherAllowed();
bool getIsDryerAllowed();
bool getIsPetsAllowed();

int compare(Appartment offCampus, Appartment onCampus);
void print();

private:
// Declaring variables
int noOfRooms;
double monthlyRent;
int sqFeet;
bool washer;
bool dryer;
bool petsAllowed;
};
#endif

____________________

Appartment.cpp

#include <iostream>
using namespace std;
#include “Appartment.h”

Appartment::Appartment()
{
}

void Appartment::setNoOfRooms(int noOfRooms)
{
this->noOfRooms = noOfRooms;
}

void Appartment::setMonthlyRent(double monthlyRent)
{
this->monthlyRent = monthlyRent;
}
void Appartment::setSqFeet(int sqFeet)
{
this->sqFeet = sqFeet;
}
void Appartment::setIsWasherAllowed(bool washer)
{
this->washer = washer;
}
void Appartment::setIsDryerAllowed(bool dryer)
{
this->dryer = dryer;
}
void Appartment::setIsPetsAllowed(bool pets)
{
this->petsAllowed = pets;
}

int Appartment::getNoOfRooms()
{
return noOfRooms;
}
double Appartment::getMonthlyRent()
{
return monthlyRent;
}
int Appartment::getSqFeet()
{
return sqFeet;
}
bool Appartment::getIsWasherAllowed()
{
return washer;
}
bool Appartment::getIsDryerAllowed()
{
return dryer;
}
bool Appartment::getIsPetsAllowed()
{
return petsAllowed;
}

int Appartment::compare(Appartment offCampus, Appartment onCampus)
{
if (onCampus.getNoOfRooms() == offCampus.getNoOfRooms()
&& onCampus.getMonthlyRent() == offCampus.getMonthlyRent()
&& onCampus.getSqFeet() == offCampus.getSqFeet()
&& onCampus.getIsWasherAllowed() == offCampus.getIsWasherAllowed()
&& onCampus.getIsDryerAllowed() == offCampus.getIsDryerAllowed()
&& onCampus.getIsPetsAllowed() == offCampus.getIsPetsAllowed())
{
return 1;
}
else
{
return 0;
}
}

void Appartment::print()
{
cout << ” NO of Rooms :” << noOfRooms << endl;

cout << “Monthly Rent :” << monthlyRent << endl;
cout << “Square Feet :” << sqFeet << endl;
if (washer)
{
cout << “Washer is Allowed .” << endl;
}
else
{
cout << “Washer is not Allowed .” << endl;
}
if (dryer)
{
cout << “Dryer is Allowed .” << endl;
}
else
{
cout << “Dryer is not Allowed .” << endl;
}

if (petsAllowed)
{
cout << “Pets are Allowed .” << endl;
}
else
{
cout << “Pets are not Allowed .” << endl;
}
}

__________________

main.cpp

#include <iostream>
using namespace std;
#include “Appartment.h”
int main()
{
// Declaring variables
int noOfRooms;
double monthlyRent;
int sqFeet;
char washer;
char dryer;
char petsAllowed;

Appartment onCampusApt;
Appartment offCampusApt;
cout << “:: OnCampus Appartment ::” << endl;
cout << “Enter No of Rooms :”;
cin >> noOfRooms;
cout << “Enter Monthly Rent :”;
cin >> monthlyRent;
cout << “Enter Sq Feet :”;
cin >> sqFeet;
cout << “Is washer Allowed (Y/N):”;
cin >> washer;
cout << “Is Dryer Allowed (Y/N):”;
cin >> dryer;
cout << “Is Pets Allowed (Y/N):”;
cin >> petsAllowed;

onCampusApt.setNoOfRooms(noOfRooms);
onCampusApt.setMonthlyRent(monthlyRent);
onCampusApt.setSqFeet(sqFeet);
if (washer == ‘Y’ || washer == ‘y’)
onCampusApt.setIsWasherAllowed(true);
else
onCampusApt.setIsWasherAllowed(false);

if (dryer == ‘Y’ || dryer == ‘y’)
onCampusApt.setIsDryerAllowed(true);
else
onCampusApt.setIsDryerAllowed(false);

if (petsAllowed == ‘Y’ || petsAllowed == ‘y’)
onCampusApt.setIsPetsAllowed(true);
else
onCampusApt.setIsPetsAllowed(false);

cout << “:: OFFCampus Appartment ::” << endl;
cout << “Enter No of Rooms :”;
cin >> noOfRooms;
cout << “Enter Monthly Rent :”;
cin >> monthlyRent;
cout << “Enter Sq Feet :”;
cin >> sqFeet;
cout << “Is washer Allowed (Y/N):”;
cin >> washer;
cout << “Is Dryer Allowed (Y/N):”;
cin >> dryer;
cout << “Is Pets Allowed (Y/N):”;
cin >> petsAllowed;

offCampusApt.setNoOfRooms(noOfRooms);
offCampusApt.setMonthlyRent(monthlyRent);
offCampusApt.setSqFeet(sqFeet);

if (washer == ‘Y’ || washer == ‘y’)
offCampusApt.setIsWasherAllowed(true);
else
offCampusApt.setIsWasherAllowed(false);

if (dryer == ‘Y’ || dryer == ‘y’)
offCampusApt.setIsDryerAllowed(true);
else
offCampusApt.setIsDryerAllowed(false);

if (petsAllowed == ‘Y’ || petsAllowed == ‘y’)
offCampusApt.setIsPetsAllowed(true);
else
offCampusApt.setIsPetsAllowed(false);

cout << “n:: Displaying OnCampus Info ::” << endl;
onCampusApt.print();
cout << “n:: Displaying OffCampus Info ::” << endl;
offCampusApt.print();

int n = offCampusApt.compare(offCampusApt, onCampusApt);
if (n == 1)
{
cout << “nTwo apartments have identical values for all Attributes.” << endl;
}
else
{
cout << “nTwo apartments have not identical values.” << endl;
}
offCampusApt.setIsPetsAllowed(true);
offCampusApt.setIsWasherAllowed(true);
offCampusApt.setIsDryerAllowed(true);
offCampusApt.setSqFeet(offCampusApt.getSqFeet() + 150);

cout << “n:: Displaying OnCampus Info ::” << endl;
onCampusApt.print();
cout << “n:: Displaying OffCampus Info ::” << endl;
offCampusApt.print();
}

________________________

Output:

Buy Essay
Calculate your paper price
Pages (550 words)
Approximate price: -

Help Me Write My Essay - Reasons:

Best Online Essay Writing Service

We strive to give our customers the best online essay writing experience. We Make sure essays are submitted on time and all the instructions are followed.

Our Writers are Experienced and Professional

Our essay writing service is founded on professional writers who are on stand by to help you any time.

Free Revision Fo all Essays

Sometimes you may require our writers to add on a point to make your essay as customised as possible, we will give you unlimited times to do this. And we will do it for free.

Timely Essay(s)

We understand the frustrations that comes with late essays and our writers are extra careful to not violate this term. Our support team is always engauging our writers to help you have your essay ahead of time.

Customised Essays &100% Confidential

Our Online writing Service has zero torelance for plagiarised papers. We have plagiarism checking tool that generate plagiarism reports just to make sure you are satisfied.

24/7 Customer Support

Our agents are ready to help you around the clock. Please feel free to reach out and enquire about anything.

Try it now!

Calculate the price of your order

Total price:
$0.00

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.

HOW OUR ONLINE ESSAY WRITING SERVICE WORKS

Let us write that nagging essay.

STEP 1

Submit Your Essay/Homework Instructions

By clicking on the "PLACE ORDER" button, tell us your requires. Be precise for an accurate customised essay. You may also upload any reading materials where applicable.

STEP 2

Pick A & Writer

Our ordering form will provide you with a list of writers and their feedbacks. At step 2, its time select a writer. Our online agents are on stand by to help you just in case.

STEP 3

Editing (OUR PART)

At this stage, our editor will go through your essay and make sure your writer did meet all the instructions.

STEP 4

Receive your Paper

After Editing, your paper will be sent to you via email.

× How can I help you?