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.

To write a program that reads city names and respective gas prices into two single-subscripted arrays, you can follow these steps:

Step 1: Declare and initialize two arrays, one of type string to store the city names and another of type double to store the gas prices. Let's name them "cities" and "gasPrices", respectively. The size of these arrays will depend on the number of cities you want to include.

Step 2: Use a loop to read the city names and gas prices from the user. You can prompt the user to enter the city name and gas price for each city, and then store the values in the corresponding arrays. For example, you can use a for loop with the loop variable "i" to iterate over the arrays and read values from the user.

Step 3: Calculate the average gas price by summing up all the gas prices and dividing by the total number of cities. You can use another loop to iterate over the gasPrices array, adding each value to a running total. Finally, divide the total by the size of the gasPrices array to find the average gas price.

Step 4: Find the highest and lowest gas prices along with the list of cities that have those prices. You can do this by using two variables, "highestPrice" and "lowestPrice", to track the maximum and minimum gas prices encountered so far. Additionally, you can create two string lists, "citiesWithHighestPrice" and "citiesWithLowestPrice", to store the corresponding city names. Use a loop to iterate over the gasPrices array, updating the highestPrice, lowestPrice, and the lists of cities accordingly.

Here's a sample implementation in C++:

```cpp
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
int numCities;
cout << "Enter the number of cities: ";
cin >> numCities;

string cities[numCities];
double gasPrices[numCities];

// Read city names and gas prices
for (int i = 0; i < numCities; i++) {
cout << "Enter the name of city " << i + 1 << ": ";
cin >> cities[i];
cout << "Enter the gas price in city " << i + 1 << ": ";
cin >> gasPrices[i];
}

// Calculate average gas price
double totalGasPrice = 0;
for (int i = 0; i < numCities; i++) {
totalGasPrice += gasPrices[i];
}
double averageGasPrice = totalGasPrice / numCities;
cout << "Average gas price: " << averageGasPrice << endl;

// Find highest gas price and cities
double highestPrice = gasPrices[0];
vector<string> citiesWithHighestPrice;
citiesWithHighestPrice.push_back(cities[0]);

for (int i = 1; i < numCities; i++) {
if (gasPrices[i] > highestPrice) {
highestPrice = gasPrices[i];
citiesWithHighestPrice.clear();
citiesWithHighestPrice.push_back(cities[i]);
} else if (gasPrices[i] == highestPrice) {
citiesWithHighestPrice.push_back(cities[i]);
}
}
cout << "Highest gas price: " << highestPrice << endl;
cout << "Cities with highest gas price: ";
for (const string& city : citiesWithHighestPrice) {
cout << city << " ";
}
cout << endl;

// Find lowest gas price and cities
double lowestPrice = gasPrices[0];
vector<string> citiesWithLowestPrice;
citiesWithLowestPrice.push_back(cities[0]);

for (int i = 1; i < numCities; i++) {
if (gasPrices[i] < lowestPrice) {
lowestPrice = gasPrices[i];
citiesWithLowestPrice.clear();
citiesWithLowestPrice.push_back(cities[i]);
} else if (gasPrices[i] == lowestPrice) {
citiesWithLowestPrice.push_back(cities[i]);
}
}
cout << "Lowest gas price: " << lowestPrice << endl;
cout << "Cities with lowest gas price: ";
for (const string& city : citiesWithLowestPrice) {
cout << city << " ";
}
cout << endl;

return 0;
}
```

Note: This implementation assumes that the user will enter valid input and does not include error handling. You may want to add input validation to handle cases where the user enters invalid input.