Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Create a class named Household that includes data fields for the number of occupants and the annual income, as well as methods to get
Create a class named Household that includes data fields for the number of occupants and the annual income, as well as methods to get and set each field. In addition, create a default constructor that automatically sets the occupants field to 1 and the income field to 0. Save this file as Household.java. Create an application named TestHousehold that demonstrates each method works correctly. Save the file as TestHousehold.java. a. Create an additional overloaded constructor for the Household class you created in Exercise 3a. This constructor receives an integer parameter and assigns the value tothe occupants field. Add any needed statements to TestHousehold to ensure that the overloaded constructor works correctly,save it, and then test it. b. Create a third overloaded constructor for the Household class you created in Exercises 3a and 3b. This constructor receives two parameters, the values of which are assigned to the occupants and income fields, respectively. Alter the TestHousehold application to demonstrate that each version of the constructor works properly. Save the application, and then compile and test it.
Step by Step Solution
★★★★★
3.47 Rating (167 Votes )
There are 3 Steps involved in it
Step: 1
Heres the implementation of the Household class and the TestHousehold application in Java as described in your question Householdjava public class Hou...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started