Write a program in a class CountPoor that counts the number of families that are considered poor.
Question:
Write a program in a class CountPoor that counts the number of families that are considered poor. Write and use a class Family that has the attributes
- income—a double value that is the income for the family
- size—the number of people in the family
and the following methods:
- Family(income, size)—a constructor that sets the attributes
- isPoor(housingCost, foodCost)—a method that returns true if housingCost + foodCost * size is greater than half the family income (foodCost is the average food cost for an individual, while housingCost is for the family)
- toString—a method that returns a string containing the information about the family
The program should read an integer k from the keyboard and then create an array of size k whose base type is Family. It should then create k objects of type Family and put them in the array, reading the income and size for each family from the keyboard. After reading an average housing cost and average food cost from the keyboard, it should display the families that are poor.
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Related Book For
Java An Introduction To Problem Solving And Programming
ISBN: 9780134462035
8th Edition
Authors: Walter Savitch
Question Posted: