Question: Hi, I need help to this problem. The Oregon Division of Consumer Affairs has commissioned as study to determine if Oregonians are paying too much
Hi, I need help to this problem.
The Oregon Division of Consumer Affairs has commissioned as study to determine if Oregonians are paying too much for gasoline. The researchers have created a data file (gasprices.txt) which contains the price of gasoline at several service stations in California, Washington, and Oregon. A specimen of the file gasprices.txt is attached as part of this assignment. You should download this file to a convenient place on your hard drive. Your assignment is to prompt the user to enter the full pathname to the data file on disk. If the file does not exist in the specified location, your program should exit with a suitable error message. The first thing your program should do is output to the screen a copy of the data read in from the disk file. This is known as echoing the input data. Your program should then calculate and display the average price of gasoline in each of California, Oregon, and Washington. Display your results to three places of decimals, and write your program to automatically list the states and their average price one to a line, in alphabetical order. You may assume for the purpose of this assignment that no place name in the file contains a space character. Next, your program should calculate and display to three places of decimals the overall average price of gasoline for all of the stations surveyed. Finally, your program should display the name of the state with the cheapest average price, and the name of the state with the highest average price.
gasprices.txt list below
Fresno Ca 2.69 Oakland Ca 2.69 Corvallis Or 2.89 Vancouver Wa 2.81 Redding Ca 2.89 Portland Or 2.79 Seattle Wa 3.09 Sacramento Ca 2.79 Bend Or 2.89 Eugene Or 2.81 Olympia Wa 2.89 Tacoma Wa 2.96 Berkeley Ca 2.71 Carmel Ca 2.73 Bellingham Wa 2.91 Centralia Wa 2.83 Beaverton Or 2.79 Medford Or 2.95 Napa Ca 2.71 Ontario Ca 2.75 Oceanside Ca 2.79
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
