Question: Suppose you own some land and would like to build three houses on it. a) Implement a House class with instance variables floorArea (a double)
Suppose you own some land and would like to build three houses on it.
a) Implement a House class with instance variables floorArea (a double) and salePrice (another double) and these methods:
i. A build method with a double floorArea parameter. This method should assign its parameter to the corresponding instance variable and print the value of its parameter.
ii. A sell method that initializes the salePrice instance variable with 150 times the value of the floorArea instance variable and then prints out the value of this salePrice.
b) Implement a Housing class with a main method that does the following:
i. Declare three variables—house (a reference to a House object), floorArea (a double), and totalFloorArea (another double, initialized to 0).
ii. Execute a for loop with three iterations. In each iteration, do this: a.Assign a random value between 1000 and 2500 to floorArea. b.Instantiate a House object and assign the result to house.
c. Call House’s build method with floorArea as argument.
d. Add floorArea to totalFloorArea.
e. Calls House’s sell method.
iii. Print the accumulated value in totalFloorArea.
Step by Step Solution
3.32 Rating (155 Votes )
There are 3 Steps involved in it
Sure lets implement these requirements step by step in Java language First well create the House cla... View full answer
Get step-by-step solutions from verified subject matter experts
