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
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.
Step by Step Solution
3.34 Rating (157 Votes )
There are 3 Steps involved in it
Step: 1
program gaspricescpp include include define max 50 usin...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