Due Date:
Friday, 22 January 2021
File(s) to be submitted:
PovertyData.java
Sample Output:
SampleOutput.html
Summary
Your task is to create a program class that reads some income data then prints a report on poverty rates.
Your program uses an array to keep track of the incomes of multiple families. It also uses various methods to calculate statistics for those families.
For an introduction to measuring poverty, see the Wikipedia page.
Watch a video about this assignment on YouTube. Or get it from the course website.
Poverty Rate Program -------------------- This program reads data on family incomes and produces a report on poverty rates among the families. By Mark Young (A00000000) Winter, 2021 ...press enter...
There must be at least two families in the country, and each income must be non-negative (that is, zero is allowed as an income). If invalid data is entered, the program requests a replacement.How many families are there in this country? 5 What is the income for family #1? 5000 What is the income for family #2? 15000 What is the income for family #3? 35000 What is the income for family #4? 55000 What is the income for family #5? 95000
What is the minimum income required to support a family? 10000
Once again,
the income must be non-negative.
If invalid data is entered,
the method requests a replacement.
The report has a title and two sections.Report ------ Average Income: $41000.0 Basic Needs Income: $10000.0 Absolute Poverty Rate: 20.0% Median Income: $35000.0 Relative Needs Income: $21000.0 Relative Poverty Rate: 40.0%
The first section is for the absolute poverty rate. It shows the average income for the families, the basic needs income, and the percent of families with income less than the basic needs income. (In this example only family #1 had an income less than $10000, and so the absolute poverty rate is 1 in 5, or 20%.)
The second section is for the relative poverty rate. It shows the median income for the families, the relative needs income, and the percent of families with income less than the relative needs income. (In this example two families has less than $21000 income, so the relative poverty rate is 2 in 5, or 40%.)
Your program uses methods as follows:
Some methods will be called more than once.
Each method must be given all the information it needs to do its job. (For example, the method to calculate the average income needs to be given the array containing all the incomes.) Methods for calculating must return the calculated values, not print them.
You also need to make appropriate use of program constants in your program. No magic numbers, please!
You are not allowed to use any other static variables.
The median of a list with an even number of elements is only a little bit harder. It's the average of the two elements in the middle. So, for example, if we'd used only the first four of the families above, the median would be the average of 15000 and 35000, which is 25000. Divide the length of the array by 2, and use that index and the one before it. So for an arry of length 4, we use locations 4/2 = 2 and 2-1 = 1 -- 35000 and 15000.
You should not be using conditional controls in this part of the program.