Java Assignment Help | Online Homework

Added on - 18 Sep 2019

  • 13

    pages

  • 1219

    words

  • 142

    views

  • 0

    downloads

Showing pages 1 to 4 of 13 pages
ContentsRating.java.......................................................................................................................................2RatingManager.java.........................................................................................................................3
Rating.javapublic class Rating {private int userId;private int itemId;private int value;public Rating(int userId, int itemId, int value) {this.userId = userId;this.itemId = itemId;this.value = value;}public int getUserId() {return userId;}public int getItemId() {return itemId;}
public int getValue() {return value;}}RatingManager.javaimport java.io.File;import java.io.FileNotFoundException;import java.util.Arrays;import java.util.LinkedList;import java.util.Scanner;import java.util.StringTokenizer;import java.util.logging.Level;import java.util.logging.Logger;public class RatingManager {private static int i = -1;private static Rating ratingAr[];
public static void main(String args[]) {ratingAr = new Rating[100000];String fileName = "src/ratings.txt";RatingManager rm = read(fileName);int itemID = 1827;System.out.println("Item rating for "+itemID);int rating[] = rm.getItemRatings(itemID);for(int r: rating){if(r == 0) break;System.out.print(r+", ");}System.out.println("\n");System.out.println("Average rating for "+itemID);double avgRating = rm.getAverageItemRating(itemID);System.out.print(avgRating+"\n\n");int userID = 6393;System.out.println("Average rating for user "+userID);double avgUserRating = rm.getAverageUserRating(userID);
desklib-logo
You’re reading a preview
card-image

To View Complete Document

Become a Desklib Library Member.
Subscribe to our plans

Download This Document