Problem

The goal of this Programming Project is to extend Programming Project 1 to find the custom...

The goal of this Programming Project is to extend Programming Project 1 to find the customer from the CSV file who made ratings that are most similar to ratings input from the keyboard. First, do Programming Project 1. Then modify your solution so that it asks the user to input ratings for the first four products before the program reads from the file. The program should then predict whether or not the user will like the final product by outputting the rating made by the most similar customer. Use the formula | Au − Ac| + | Bu −  Bc| + | Cu −  Cc| + | Du −  Dc| to compute the similarity, where Au is the rating for product A made by the user at the keyboard and Ac is the rating for product A made by a customer from the file. A lower total indicates greater similarity. For example, if the user inputs 1 for product A, 1 for product B, 3 for product C, and 2 for product D, then with the values from Programming Project 1, the similarity to the customer in the first row is |1 − 3| + |1 − 0| + |3 −  5| + |2 − 1| = 6, while the similarity to the customer in the second row is |1 −  1| + |1 −  1| + |3 −  4| + |2 −  2| = 1. The customer in the second row has the greatest similarity, so the program would output that the prediction for product E is 1, which is the second customer’s rating for product E.

Programming Project 1

A comma-separated values (CSV) file is a simple text format used to store a list of records. A comma is used as a delimiter to separate the fields for each record. This format is commonly used to transfer data between a spreadsheet or database. In this Programming Project, consider a store that sells five products abbreviated as A, B, C, D, and E. Customers can rate each product from 1–5, where 1 is poor and 5 is excellent. The ratings are stored in a CSV file where each row contains the customer’s rating for each product. Here is a sample file with three customer ratings:

In this file format, the first line gives the products. The digit 0 indicates that a customer did not rate a product. In this case, the first customer rated A as 3, C as 5, D as 1, and E as 2, Product B was not rated. The third customer rated C as 5, D as 1, and E as 3. The third customer did not rate A or B.

Create a text file in this format with sample ratings. Then, write a program that reads in this text file and extracts each rating using the stringTokenizer class. Finally, the program should output the average rating for each product. Customers that did not rate a product should not be considered when computing the average rating for that product. Your program can assume there will always be exactly five products but it should work with an arbitrary number of customer ratings.

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 4