Programming Assignment 19

 

The results of a survey of the households in your township have been tabulated.  Each line contains data for one household, including the family name, the annual income for the family, and the number of household members.  There are an arbitrary number of families in the data file (no more than 50).

 

1.         Use a function to read the input data and count the number of households in the survey.  You need an EOF loop.  Print the number of households.

2.         Use a function to calculate the average income.  Print it as dollars and cents.

3.         Use a function to print the names of all households that exceed the average income.

4.         Use a function to calculate the percentage of households that fall below the poverty line. Print the percentage of households that fall below the poverty level.   The poverty level income may be computed by the formula

                                        poverty level = $7500 + $1500 * (members - 2)

 

Input data

 

Smith     $14000    2

Jones     $ 7500    5

Brown     $28000    1

Green     $55000    4

Black     $12000    7

White     $39000    4

 

Output

 

Number of households = 6

Average income = $25916.67

Above average income families:

    Brown

    Green

    White

Percentage below poverty level = 33%

 

Functions

 

void ReadData(string name[], float income[], int members[], int& number);

float Average(float income[], int number);

void AboveAverage(string name[], float income[], float average, int number);

float percentage(float income[], int members[], int number);