Can you change a bit of the code to out put the monthly rent with two decimals. Thanks! #include #include #include using namespace std; class RealProperty{ private: // streetAddress that hold the street address string streetAddress; // squareFoot that hold the square footage int squareFoot; // taxes that hold the taxes double taxes; public: // default constructor of RealProperty class it's initlizes the fields RealProperty(){ streetAddress = ""; squareFoot = 0; taxes = 0.0; } // parameterized constructor of RealProperty class RealProperty(string sAddress, int sqFootage, double tax){ streetAddress = sAddress; squareFoot = sqFootage; taxes = tax; } // setStreetAddress function for set the street address void setStreetAddress(string sAddress){ streetAddress = sAddress; } //setSquareFootage function for set the square footage void setSquareFootage(int sqFootage){ if(sqFootage > 0){ squareFoot = sqFootage; } else cout << "Square footage must be a positive number." << endl; } // setTaxes function for the set taxes void setTaxes(double tax){ taxes = tax; } string getStreetAddress()const; int getSquareFoot()const; double getTaxes()const; }; // return string RealProperty::getStreetAddress()const{ return streetAddress; } // getSquareFootage function return the square footage int RealProperty::getSquareFoot()const{ return squareFoot; } // getTaxes return the taxes double RealProperty::getTaxes()const{ return taxes; } // Apartment class class Apartment:public RealProperty{ private: double rent; public: // constructor of Apartment Apartment():RealProperty(){rent = 0.0;} // Parameter constructor of Apartment Apartment(string sAddress, int sqFootage, double taxes,double mRent) :RealProperty(sAddress,sqFootage,taxes){rent = mRent;} // setMonthlyRent use for changing the monthly rent. void setMonthlyRent(int mRent){ rent = mRent; } // getMonthlyRent retunr the monthly rent double getMonthlyRent()const{ return rent; } }; //****************************************************************************** //* Print the real property information. //* //* Parameter //* rp - a reference to const referencing to caller's RealProperty //* variable. //* //* Return //* void //****************************************************************************** void displayPropertyInfo(const RealProperty &rp) { // Write your code here . . . cout << "Property is located at: " << rp.getStreetAddress() << endl; cout << "Square footage: " << rp.getSquareFoot() << endl; cout << "Taxes: " << rp.getTaxes() << "\n" << endl; } //****************************************************************************** //* Print the apartment information. //* //* Parameter //* rp - a reference to const referencing to caller's Apartment //* variable. //* //* return //* void //****************************************************************************** void displayApartmentInfo(const Apartment &apt) { cout << "Apartment is located at: " << apt.getStreetAddress() << endl; cout << "Square footage: " << apt.getSquareFoot() << endl; cout << "Taxes: " << apt.getTaxes() <

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Can you change a bit of the code to out put the monthly rent with two decimals. Thanks!

#include <iostream>
#include <iomanip>
#include <string>
using namespace std;

class RealProperty{

private:
// streetAddress that hold the street address
string streetAddress;
// squareFoot that hold the square footage
int squareFoot;
// taxes that hold the taxes
double taxes;

public:
// default constructor of RealProperty class it's initlizes the fields
RealProperty(){
streetAddress = "";
squareFoot = 0;
taxes = 0.0;
}

// parameterized constructor of RealProperty class
RealProperty(string sAddress, int sqFootage, double tax){
streetAddress = sAddress;
squareFoot = sqFootage;
taxes = tax;
}

// setStreetAddress function for set the street address
void setStreetAddress(string sAddress){
streetAddress = sAddress;
}

//setSquareFootage function for set the square footage
void setSquareFootage(int sqFootage){
if(sqFootage > 0){
squareFoot = sqFootage;
}
else
cout << "Square footage must be a positive number." << endl;
}

// setTaxes function for the set taxes
void setTaxes(double tax){
taxes = tax;
}
string getStreetAddress()const;
int getSquareFoot()const;
double getTaxes()const;

};

// return
string RealProperty::getStreetAddress()const{
return streetAddress;
}

// getSquareFootage function return the square footage
int RealProperty::getSquareFoot()const{
return squareFoot;
}

// getTaxes return the taxes
double RealProperty::getTaxes()const{
return taxes;
}

// Apartment class
class Apartment:public RealProperty{

private:
double rent;
public:
// constructor of Apartment
Apartment():RealProperty(){rent = 0.0;}

// Parameter constructor of Apartment
Apartment(string sAddress, int sqFootage, double taxes,double mRent)
:RealProperty(sAddress,sqFootage,taxes){rent = mRent;}

// setMonthlyRent use for changing the monthly rent.
void setMonthlyRent(int mRent){
rent = mRent;
}

// getMonthlyRent retunr the monthly rent
double getMonthlyRent()const{
return rent;
}
};

//******************************************************************************
//* Print the real property information.
//*
//* Parameter
//* rp - a reference to const referencing to caller's RealProperty
//* variable.
//*
//* Return
//* void
//******************************************************************************
void displayPropertyInfo(const RealProperty &rp) {

// Write your code here . . .
cout << "Property is located at: " << rp.getStreetAddress() << endl;
cout << "Square footage: " << rp.getSquareFoot() << endl;
cout << "Taxes: " << rp.getTaxes() << "\n" << endl;

}

//******************************************************************************
//* Print the apartment information.
//*
//* Parameter
//* rp - a reference to const referencing to caller's Apartment
//* variable.
//*
//* return

//* void
//******************************************************************************
void displayApartmentInfo(const Apartment &apt) {

cout << "Apartment is located at: " << apt.getStreetAddress() << endl;
cout << "Square footage: " << apt.getSquareFoot() << endl;
cout << "Taxes: " << apt.getTaxes() <<endl;
cout << "Monthly rent: " << apt.getMonthlyRent() << endl;

}

int main() {

Apartment lakeside("Cupertino",1200,200,2550);

// call displayPropertyInfo function
displayPropertyInfo(lakeside);

// call the displayApartmentInfo function
displayApartmentInfo(lakeside);

return 0;
}

Use the following line as your program input:
Cupertino, 1200, 200, 2550
The output should look exactly as follows:
Property is located at: Cupertino
Square footage: 1200
Taxes: 200
Apartment is located at: Cupertino
Square footage: 1200
Taxes: 200
Monthly rent: 2550.00
Transcribed Image Text:Use the following line as your program input: Cupertino, 1200, 200, 2550 The output should look exactly as follows: Property is located at: Cupertino Square footage: 1200 Taxes: 200 Apartment is located at: Cupertino Square footage: 1200 Taxes: 200 Monthly rent: 2550.00
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Concept of pointer parameter
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education