Java program to read from a .csv file containing rates from power companies. Your program should determine
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 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
Statistical Reasoning for Everyday Life
ISBN: 978-0321817624
4th edition
Authors: Jeff Bennett, Bill Briggs, Mario F. Triola