"The program instantiates and uses instances of a derived class with default and parameterized constructors. Write A Base Class Declare a class named RealProperty that could be used to describe a piece of real property. It should contain these private fields: streetAddress (string) squareFootage (int) taxes (double) Each field should have a comment documenting what it is for. Add public member functions as follows: The default constructor. The default constructor initializes the fields so that the street address is an empty string and all numeric fields are 0 or 0.0. Implement the default constructor inline using the member initialization list syntax. The constructor that accepts these data: street address (string), square footage (int), and taxes (double). Implement this constructor inline using the member initialization list syntax and call the mutator function for square footage in the body of the constructor. Add mutator member functions to set the fields. One member function for each field. Each member function should begin with the word 'set' followed by the field name with the first letter changed to uppercase. Each member function should have a comment above the declaration describing its purpose. Implement the mutator member functions outside of the class. Add accessor member functions to return the fields. One member function for each field. Each member function should begin with the word 'get' followed by the field name with the first letter changed to uppercase and the function should be marked with the const keyword. Each member function should have a comment above the declaration describing its purpose. Implement the accessor member functions inline. Write the definition for all member functions not defined inline. Validate the square footage to make sure it is a positive number. If the square footage is not positive, Issue the message, "Square footage must be a positive number." and terminate the running of the program. Write A Derived Class Declare a class named Apartment that could be used to describe a kind of real property. It is a class derived from RealProperty publicly. It should contain one private field: monthlyRent (double) Use the data type in parentheses for the field. Each field should have a comment documenting what it is for. Add public member functions as follows: Add the default constructor. The default constructor initializes the fields through a member initialization list so that the street address is an empty string and all numeric fields are 0 or 0.0. Note you need to use a special syntax to initialize the private fields of the base class. Implement this constructor inline. Add a constructor that accepts: rent (double), street address (string), square footage (int), and taxes (double). This constructor sets all the fields based on four parameters: street address, square footage, taxes, and monthly rent through a member initialization list. Note you need to use a special syntax to initialize the private fields of the base class. Implement this constructor inline. Add mutator member functions to set the fields. One member function for each field. Each member function should begin with the word 'set' followed by the field name with the first letter changed to uppercase. Each member function should have a comment above the declaration describing its purpose. Implement the mutator member function inline. Add accessor member functions to return the fields. One member function for each field. Each member function should begin with the word 'get' followed by the field name with the first letter changed to uppercase and the member function should be a const member function. Each member function should have a comment above the declaration describing its purpose. Implement the accessor member functions inline. Write the definition for all member functions not implemented inline. Declare a function named displayPropertyInfo that receives one reference to const parameter representing a real property. The function has no return value. Declare a function named displayApartmentInfo that receives one reference to const parameter representing an apartment. The function has no return value. Write the main function as follows: Define an Apartment variable named lakeside. Get the info from user by reading a line of user input that contains info in the following format: Cupertino, 1200, 200, 2550 The line above includes the street address, square footage, taxes and monthly rent in that order. Note: don't prompt the user in your code. Store the info in the variable lakeside. Call displayPropertyInfo and pass the Apartment variable lakeside. Call displayApartmentInfo and pass the same Apartment variable lakeside. End of main function. Write the definition of displayPropertyInfo below the main function. Don't forget the block comment. Write the definition of displayApartmentInfo below the displayPropertyInfo function. Don't forget the block comment. First in the picture is program input and second is output

COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
1st Edition
ISBN:9780357392676
Author:FREUND, Steven
Publisher:FREUND, Steven
Chapter5: Working With Multiple Worksheets And Workbooks
Section: Chapter Questions
Problem 4AYK
icon
Related questions
Question

"The program instantiates and uses instances of a derived class with default and parameterized constructors.

Write A Base Class

Declare a class named RealProperty that could be used to describe a piece of real property. It should contain these private fields:

streetAddress (string)

squareFootage (int)

taxes (double)

Each field should have a comment documenting what it is for.

Add public member functions as follows:

The default constructor. The default constructor initializes the fields so that the street address is an empty string and all numeric fields are 0 or 0.0. Implement the default constructor inline using the member initialization list syntax.

The constructor that accepts these data: street address (string), square footage (int), and taxes (double). Implement this constructor inline using the member initialization list syntax and call the mutator function for square footage in the body of the constructor.

Add mutator member functions to set the fields. One member function for each field. Each member function should begin with the word 'set' followed by the field name with the first letter changed to uppercase. Each member function should have a comment above the declaration describing its purpose. Implement the mutator member functions outside of the class.

Add accessor member functions to return the fields. One member function for each field. Each member function should begin with the word 'get' followed by the field name with the first letter changed to uppercase and the function should be marked with the const keyword. Each member function should have a comment above the declaration describing its purpose. Implement the accessor member functions inline.

Write the definition for all member functions not defined inline. Validate the square footage to make sure it is a positive number. If the square footage is not positive, Issue the message,

"Square footage must be a positive number."

and terminate the running of the program.

Write A Derived Class

Declare a class named Apartment that could be used to describe a kind of real property. It is a class derived from RealProperty publicly. It should contain one private field:

monthlyRent (double)

Use the data type in parentheses for the field.

Each field should have a comment documenting what it is for.

Add public member functions as follows:

Add the default constructor. The default constructor initializes the fields through a member initialization list so that the street address is an empty string and all numeric fields are 0 or 0.0. Note you need to use a special syntax to initialize the private fields of the base class. Implement this constructor inline.

Add a constructor that accepts: rent (double), street address (string), square footage (int), and taxes (double). This constructor sets all the fields based on four parameters: street address, square footage, taxes, and monthly rent through a member initialization list. Note you need to use a special syntax to initialize the private fields of the base class. Implement this constructor inline.

Add mutator member functions to set the fields. One member function for each field. Each member function should begin with the word 'set' followed by the field name with the first letter changed to uppercase. Each member function should have a comment above the declaration describing its purpose. Implement the mutator member function inline.

Add accessor member functions to return the fields. One member function for each field. Each member function should begin with the word 'get' followed by the field name with the first letter changed to uppercase and the member function should be a const member function. Each member function should have a comment above the declaration describing its purpose. Implement the accessor member functions inline.

Write the definition for all member functions not implemented inline.

Declare a function named displayPropertyInfo that receives one reference to const parameter representing a real property. The function has no return value.

Declare a function named displayApartmentInfo that receives one reference to const parameter representing an apartment. The function has no return value.

Write the main function as follows:

Define an Apartment variable named lakeside.

Get the info from user by reading a line of user input that contains info in the following format:

Cupertino, 1200, 200, 2550

The line above includes the street address, square footage, taxes and monthly rent in that order.

Note: don't prompt the user in your code.

Store the info in the variable lakeside.

Call displayPropertyInfo and pass the Apartment variable lakeside.

Call displayApartmentInfo and pass the same Apartment variable lakeside.

End of main function.

Write the definition of displayPropertyInfo below the main function. Don't forget the block comment.

Write the definition of displayApartmentInfo below the displayPropertyInfo function. Don't forget the block comment.

First in the picture is program input and second is output.

 

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
16
38
17 tinclude <iostream>
18 tinclude <iomanip>
19 tinclude <string>
39 eint main() {
40
// Write code here
20
41
21 using namespace std;
42
22
43
return 0;
23 || Write the code for class RealProperty here
44
24
45
25
46 //***
k****
26 || Write the code for class Apartment here ...
47 |/* Print the real property information.
48 //*
49 |/* Parameter
50 //*
27
28 || Function prototypes
29
rp - a reference to const referencing to caller's RealProperty
30 || Declare a function named displayPropertyInfo that receives one reference to const parameter
31 |/ representing a real property. The function has no return value.
51 //*
variable.
52 //*
32
33
53 //* Return
54 //*
void
34 // Declare a function named displayApartmentInfo that receives one reference to const parameter
35 |/ representing an apartment. The function has no return value.
55 //****
k***:
36
56 Evoid displayPropertyInfo(const RealProperty &rp) {
37
57
// Write your code here
38
58
39 gint main() {
59 }
40
// Write code here .
60
41
61 |/**
****:
42
62 //* Print the apartment information.
63 //*
43
return 0;
44
64 //* Parameter
65 //*
45
rp - a reference to const referencing to caller's Apartment
46 |/
47 |/* Print the real property information.
不不平不
66 //*
variable.
67 |/*
68 //* Return
48 //*
49 |/* Parameter
50 //*
rp - a reference to const, referencing to caller's RealProperty
69 //*
void
51 //*
variable.
70 //*****
**
52 |/*
71 Evoid displayApartmentInfo(const Apartment &apt) {
53 //* Return
72
// Write your code here
54 //*
void
73
55 //*
k***********
74
56 svoid displayPropertyInfo(const RealProperty &rp) {
// Write your code here
75 }
57
76
Transcribed Image Text:16 38 17 tinclude <iostream> 18 tinclude <iomanip> 19 tinclude <string> 39 eint main() { 40 // Write code here 20 41 21 using namespace std; 42 22 43 return 0; 23 || Write the code for class RealProperty here 44 24 45 25 46 //*** k**** 26 || Write the code for class Apartment here ... 47 |/* Print the real property information. 48 //* 49 |/* Parameter 50 //* 27 28 || Function prototypes 29 rp - a reference to const referencing to caller's RealProperty 30 || Declare a function named displayPropertyInfo that receives one reference to const parameter 31 |/ representing a real property. The function has no return value. 51 //* variable. 52 //* 32 33 53 //* Return 54 //* void 34 // Declare a function named displayApartmentInfo that receives one reference to const parameter 35 |/ representing an apartment. The function has no return value. 55 //**** k***: 36 56 Evoid displayPropertyInfo(const RealProperty &rp) { 37 57 // Write your code here 38 58 39 gint main() { 59 } 40 // Write code here . 60 41 61 |/** ****: 42 62 //* Print the apartment information. 63 //* 43 return 0; 44 64 //* Parameter 65 //* 45 rp - a reference to const referencing to caller's Apartment 46 |/ 47 |/* Print the real property information. 不不平不 66 //* variable. 67 |/* 68 //* Return 48 //* 49 |/* Parameter 50 //* rp - a reference to const, referencing to caller's RealProperty 69 //* void 51 //* variable. 70 //***** ** 52 |/* 71 Evoid displayApartmentInfo(const Apartment &apt) { 53 //* Return 72 // Write your code here 54 //* void 73 55 //* k*********** 74 56 svoid displayPropertyInfo(const RealProperty &rp) { // Write your code here 75 } 57 76
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Class
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
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
Computer Science
ISBN:
9780357392676
Author:
FREUND, Steven
Publisher:
CENGAGE L
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage