CS 1401, Quiz 12, TR version

Date: Thursday, November 21, 2013
Name (please type legibly, ideally in block letters): ______________________________________________________________________

The price of gas changed day by day. Every day when you fill in your gas tank, the price of gas can be computed by dividing the total amount that you paid for gas by the number of gallons that you bought. Write a method that, given:

returns the price of gas of this day. For example, if the index is i = 3, the amount of money that you paid for gas on the corresponding day is amount[3] = 18 and the number of gallons that you bought on this day is gallons[3] = 6, your method should return 3. Use try-catch to catch both possible exceptions: Return −1 if the first exception occurs and −2 if the second exception occurs.