In the exercises in Chapter 7, you designed a class named house that holds the s
ID: 3635673 • Letter: I
Question
In the exercises in Chapter 7, you designed a class named house that holds the street address, asking price, number of bedrooms, and number of baths in a house. Design a class named soldhouse that descends from house and includes fields that hold the selling price and the ratio of the selling price to the asking price. The soldhouse class contains a method that sets the selling price and computes the ratio by dividing the selling price by the asking price. The class also contains methods to get the selling price and the ratio. Design an application that instantiates a SoldHouse object and demonstrates all its methods.Explanation / Answer
class house { public: char streetAdd[30]; float askingPrice; int noOfBedRooms; int noOfBath; }; class soldHouse:public house { float sellingPrice; int ratio; void setSellingPrice(float sellPrice) { sellingPrice=sellPrice; } void setRatio() { ratio=sellingPrice/askingPrice; } float getSellingPrice() { return sellingPrice; } int getRatio() { return ratio; } };
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.