Suppose you own some land and would like to build three houses on it. a) Implement a

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) 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.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: