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
Step: 1
Java implementation using CSV file available at httpscatalogdatagovdatasetuselectricutilitycompanies...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