1)Use java to create a class named Household that includes data fields for the household name, number of occupants and the total monthly household income. In your class, include the following methods:...


1)Use java to create a class named Household that includes data fields for the household name, number
of occupants and the total monthly household income. In your class, include the following
methods:
• A method to calculate and return the average income per occupant. Use the following
method header:
double computeAverageIncome()


IMPORTANT NOTE: Remember to adhere to the standard Java naming convention for


your class names, data field names and method names.


Write a test program named to test your Household class by
• creating a Household object called h1
• assign values to the data fields
• displaying h1’s data field values


Add the following constructors to the Household
class.
(i) A no-argument constructor that sets the household name, the occupant’s field and the
income field.


Then a constructor with 3 parameters. This constructor receives string, integer and double
arguments. Assigns the argument’s value to the name, occupant field and income. Display the value using h2 object in your test file.
As always, you need to test your operations: Modify the test program to demonstrate that each overloaded constructor works properly by creating 2 different objects using the 2 different constructors.


penerai Output<br>-Configuration: <Default>.<br>Name: Ong<br>Number of occupant: 2<br>Total monthly household income: 1000.0<br>Average income per occupant: RM500.00<br>Name: Lee<br>Number of occupant: 3<br>Total monthly household income: 2000.0<br>Average income per occupant: RM666.67<br>Process completed.<br>

Extracted text: penerai Output -Configuration: . Name: Ong Number of occupant: 2 Total monthly household income: 1000.0 Average income per occupant: RM500.00 Name: Lee Number of occupant: 3 Total monthly household income: 2000.0 Average income per occupant: RM666.67 Process completed.
Jun 10, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here