CS
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:
- 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,
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[1] = 10,000 and
the population of this country is population[1] = 1,000, your method should return 10.
Use try-catch to catch both possible exceptions:
- an exception arising when the index i is too large, larger than (or equal to)
the number of elements in one of the given
arrays; and
- an exception arising when we try to divide by 0.
Return −1 if the first exception occurs and −2 if the second exception occurs.