Question: Create a C + + program that contains the following functions: a . void displayCarDetails ( string [ ] , double [ ] , int

Create a C++ program that contains the following functions:
a. void displayCarDetails(string[], double[], int): This function takes two parallel arrays (cars and mpg) and their size as input. It displays the car details, including car name, MPG, and whether it is "Economical" or a "Gas Guzzler" based on its MPG value.
Pre-populate two parallel arrays with 5 elements each:
a. cars[]: This string array will hold the names of 5 cars (e.g., "Car A", "Car B", etc.).
b. mpg[]: This double array will hold the MPG values of the corresponding cars.
Use the displayCarDetails function to output the car details.
The program should calculate whether a car is "Economical" or a "Gas Guzzler" based on the following rule:
If the MPG is greater than 30.0, the car is considered "Economical."
Otherwise, the car is considered a "Gas Guzzler."
add a function that returns the average mpg of all 5 cars

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!