Question: Java program to read from a .csv file containing rates from power companies. Your program should determine the average commercial rate, and also display the

Java program to read from a .csv file containing rates from power companies. Your program should determine the average commercial rate, and also display the information for the highest and lowest rates found.

The data file you will use is freely available from data.gov, however a slightly cleaned-up version of it has been prepared and is available as described below (please use that one). It lists the commercial (comm_rate), industrial (ind_rate), and residential (res_rate) rates for each zip code.

Your program should do the following:

  • Prompt the user for a filename.
  • Open the requested file and read through it line by line.
  • Ignore the first line, as it contains header information.
  • Find the column for comm_rate and keep track of it as needed. (You may assume the file will have a consistent ordering of columns.)
  • After parsing through the complete file, display the average (mean) commercial rate across all zip codes.
  • Display the utility company, zip code, state, and rate for the zip code with the highest commercial rate in the file.
  • Display the utility company, zip code, state, and rate for the zip code with the lowest commercial rate in the file.
  • If there is a tie for the highest or lowest rate, you should display the zip code that came first in the file.

Sample Output:

The following is an example of the output that should be generated:

Please enter the data file: rates.csv

The average commercial rate is: 0.08402623352821378

The highest rate is:

Napakiak Ircinraq Power Co (99634, AK) - $0.839779005525

The lowest rate is:

Sierra Pacific Power Co (89496, NV) - $0.0

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Java implementation using CSV file available at httpscatalogdatagovdatasetuselectricutilitycompanies... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!