Computer Science 230 – Assignment 1

Learning objectives: Review arrays.


A survey of the households in a town is being scrutinized for families
below the poverty level.  Each record
contains data for one household, including a four-digit identification number,
the annual income for the household, and the number of household members.
Create a class, Household, that contains an ID number
(an int), an income (a double), and a number
of household members (an int).  Enter the data via the constructor. You will
need a getter for each field, but no setters are needed for this program.


Create a class, HouseholdStatistics, with a main() method.  Read from standard input the name of a text
file, then read the survey results from the file until all have been read.  Assume that each line of the file contains
one ID number, one income, and one number of household members.  As you read the data create a Household object and put
the data into it. Then put the object into an array or ArrayList of Household objects.  Assume that no more than 25 households were
surveyed. Print a three-column table displaying the data as shown below.  Calculate and display the average household
income and display a list of the identification numbers of the households that
exceed the average, separated by commas. 


Determine the percentage of households with incomes below the poverty
level.  Compute the poverty level income
using the formula, p = $6500.00 + $750 * (m-2), where m is the
number of members of the household. Thus the poverty level increases as m gets
larger. (Warning: as given this formula may introduce a program bug.)  List the identification numbers of the
households that are below the poverty level, separated by commas.



Identification Number   Annual Income     Household members

1041                       $12180.00      4

1062                       $13240.00      3

1327                       $19800.00      2

1483                       $22458.00      8

1900                       $17000.00      2

2112                       $18125.00      7

2345                       $15623.00      2

3210                        $3200.00      6

3600                        $6500.00      5

3601                       $11970.00      2

4725                        $8900.00      3

6217                       $10000.00      2

9280                        $6200.00      1


Average income = $12701.23

Households above the average income:

1062, 1327, 1483, 1900, 2112, 2345

Households below the poverty level:

3210, 3600, 9280

Powered by