1401, Quiz 12, MW 9-10:20 version
Date: Wednesday, November 20, 2013
Name (please type legibly, ideally in block letters):
For each county, income-per-person can be obtained by dividing the overall income of the county
by its population. Write a method that, given:
returns the income-per-person in this county. For example, if the index is i = 1, the overall income of the
corresponding country is overall = 10,000 and
the population of this country is population = 1,000, your method should return 10.
Use try-catch to catch both possible exceptions:
- an array overall containing overall incomes of different counties,
- an array population containing populations of different counties, and
- the index i of the current county,
Return −1 if the first exception occurs and −2 if the second exception occurs.
- an exception arising when the index i is too large, larger than (or equal to)
the number of elements in one of the given
- an exception arising when we try to divide by 0.