java assignment

profilesehj
a2_ex2.html

COMP 1020

 

Exercise 2

The program works well, but it makes some assumptions about the way movie ratings are stored. All the ratings have to be in the same scale (e.g. in this example, they are all out of 10), but often reviews use different scales (stars out of 5, percentages out of 100). Change the program to allow the program to use different scales, but keep the final results as numbers out of 10. The range of the scale will be added as an extra input line for each movie. For example:

Casablanca
8.7
10.0
Toy Story
8.1
10.0
Star Wars Episode IV
88.0
100.0
Toy Story
4.0
5.0

The first two ratings are out of 10 as before, but the third is 88 out of 100, and the last rating is 4 out of 5 stars.

Download the complete Movie Reviews program and add the following features to it:

  1. Read three lines for each movie instead of two. Start out by just printing the data from the extra line.
  2. Convert the third line into a double (outOf) and scale the rating by dividing it by outOf and multiplying the result by 10. Use this as the movie's rating out of 10 when creating or modifying a review. Note that the conversion of this value should also occur inside the nested "try" block. Since the error message in the "catch" may apply to an invalid rating or an invalid outOf value, change it appropriately.

Submit only the complete file input try-catch block (and not the rest of the main program, or any other methods or classes) by the due date specified in the course schedule.