Question: In basic C++ please. Define a structure, named CarInfo, that contains three member variables, Make (a string), Model (a string), and Year (an integer). Write
In basic C++ please.
Define a structure, named CarInfo, that contains three member variables, Make (a string), Model (a string), and Year (an integer).
Write a program that takes the user input of a number of cars' information including their model, make and year. The input starts with an integer indicating the number of cars that will follow. Each car's information is entered in a separate line. The model, make, and year information of each car are separated by whitespaces. You can safely assume that the number of cars is no more than 10. The following shows an example input
3 Nissan Versa 2012 Ford Explorer 2020 Nissan Sentra 2020
(1) The program then outputs the car information received. For example, given the above input, the program will output
You entered: Nissan Versa 2012 Ford Explorer 2020 Nissan Sentra 2020
(2) Next, the program will get a year (integer) from the user and print all cars made during or after that year. For example, if the integer entered is 2020, given the input above the output would be:
Cars produced after 2020 in inventory: Ford Explorer 2020 Nissan Sentra 2020
If no car is found, print the message:
No car produced afterin inventory.
The array search and output must be produced by a function:
bool printCarsByYear(CarInfo cars[], int nCars, int year);
Additionally, the function will return false if no car in the array matches the search information; otherwise, it will return true. Call the function in main to complete the search and print the output. If these tasks are not completed by the function or the function is not called correctly, the corresponding test case(s) will be considered failed.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
