Write a complete C++ program that solves the following problem. Give your source
ID: 3539481 • Letter: W
Question
Write a complete C++ program that solves the following problem. Give your source file a meaningful name, such as gasprices.cpp. Do not use any global data except for any constant values you may need and your file stream variables.
1. Create a datafile that contains the names of 50 cities and their respective gas prices. You can look these up online, use local prices, and/or make up a few (as long as your prices are reasonable!). Your city names should be a single string with no spaces in them to simplify the reading process.
2. Write a program reads the city names and respective gas prices into 2 single-subscripted arrays in your program - one of type string, the other of type double. (We would call these "parallel arrays" - each corresponding location shows the city name and gas price for each city). Your program should do the following:
a. Find and display the average gas price.
b. Find and display the highest gas price, along with a list of all cities at that gas price.
c. Find and display the lowest gas price, along with a list of all cities at that gas price.
Your program must use at least 2 well-defined functions. You can, if you wish, use more. Direct all output to the console window. All output should be well labeled and formatted.
Explanation / Answer
gasPrice.txt file entries:
starts from here
dehli 75.60
bhopal 74.98
indore 74.58
alwar 73.30
bikaner 72.00
banglore 70.50
kuwait 75.60
agra 75.60
bihar 72.00
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.