Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

More Books

Students also viewed these Programming questions

Question

=+a. Arm and Hammer: http://www.armandhammer.com

Answered: 1 week ago