Question
java 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
java
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 15, where 1 is poor
and 5 is excellent. The ratings are stored in a CSV file where each row contains
the customers rating for each product. Here is a sample file with three customer
ratings:
A,B,C,D,E
3,0,5,1,2
1,1,4,2,1
0,0,5,1,3
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
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started