Java Reference
In-Depth Information
Allow the user to enter a name.
If the name exists in the map, then output all usernames that are one link away
from the user entered.
If the name exists in the map, then output all usernames that are two links away
from the user entered. To accomplish this in a general way, you might consider
writing a recursive subroutine.
Do not forget that your User class must override the hashCode and equals methods.
8. You have collected a file of movie ratings where each movie is rated from 1 (bad)
to 5 (excellent). The first line of the file is a number that identifies how many rat-
ings are in the file. Each rating then consists of two lines: the name of the movie
followed by the numeric rating from 1 to 5. Here is a sample rating file with four
unique movies and seven ratings:
7
Harry Potter and the Half-Blood Prince
4
Harry Potter and the Half-Blood Prince
5
Army of the Dead
1
Harry Potter and the Half-Blood Prince
4
Army of the Dead
2
The Uninvited
4
Pandorium
3
Write a program that reads a file in this format, calculates the average rating for
each movie, and outputs the average along with the number of reviews. Here is the
desired output for the sample data:
Harry Potter and the Half-Blood Prince: 3 reviews, average of 4.3 / 5
Army of the Dead: 2 reviews, average of 1.5 / 5
The Uninvited: 1 review, average of 4 / 5
Pandorium: 1 review, average of 3 / 5
Use a HashMap or multiple HashMaps to calculate the output. Your map(s) should
index from a string representing each movie's name to integers that store the num-
ber of reviews for the movie and the sum of the ratings for the movie.
9. The file words.txt included on the website contains a list of 87,314 English words.
Write a program that uses this word list to implement a simple spell-checker. First,
read all of the words into a HashSet<String> object. Then, allow the user to enter
the name of a text file that contains written English. The program should output
all of the words that are not in the set as potentially misspelled words.
Search WWH ::




Custom Search