Assume the existence of a Building class . Define a derived class , ApartmentBui
ID: 3556122 • Letter: A
Question
Assume the existence of a Building class . Define a derived class , ApartmentBuilding that contains four (4) data members: an integer named numFloors, an integer named unitsPerFloor, a boolean named hasElevator, and a boolean named hasCentralAir. There is a constructor containing parameters for the initialization of the above variables (in the same order as they appear above). There are also two function: the first, getTotalUnits, accepts no parameters and returns the total number of units in the building; the second, isLuxuryBuilding accepts no parameters and returns true if the building has central air, an elevator and 2 or less units per floor.
Explanation / Answer
#include <iostream>
#include <string>
using namespace std;
class Numbers
{
private:
int number;
public:
static const string words_array[32];
// prototypes
void print();
Numbers();
Numbers(int x);
};
Numbers::Numbers(int number_in) : number(number_in) {}
const string Numbers::words_array[32] = { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten",
"eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen", "twenty", "thirty", "fourty", "fivety",
"sixty", "seventy", "eighty", "ninety", "hundred", "thousand" };
//print function
void Numbers::print()
{
cout << number;
}
int main()
{
cout << "Please enter a whole dollar amount between 0 through 9999: ";
int number;
cin >> number;
while (number >= 0)
{
// Create a Numbers object
Numbers n(number);
// Print the English description
n.print();
// Get another number
cout << " Enter another number: ";
cin >> number;
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.