Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Object oriented question Define a class named Household that has data members for the number of occupants and the annual income. Add the followings to

Object oriented question

Define a class named Household that has data members for the number of occupants and the annual income. Add the followings to the class Household: (a) A constructor that requires no argument and sets the occupants to 1 and the income to 0. (b) A constructor that receives two arguments, the value of which are assigned to the occupants and income instance variables respectively.

(c) Individual get and set methods for each data member

(d) toString() method which returns a String, for example, "Household: 4 occupants with annual income RM8000.00" where 4 is the number of occupants of the Household and 8000 is the annual income of the Household.

Write a main class that creates 2 objects of Household. Assign appropriate information for each of the object (using input data is an optional). The program then displays each Household's information and the average income.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Construct a WBS for the project in Question 19.

Answered: 1 week ago

Question

=+Where do you want to live and work?

Answered: 1 week ago