Question
Description For this assignment, you will create a car database for a dealership. You will have a struct that will hold each cars information. The
Description
For this assignment, you will create a car database for a dealership. You will have a struct that will hold
each cars information. The struct will be
struct automobile
{
string make ;
string model ;
unsigned int year ;
string color ;
usigned int msrp
};
Implementation details
In your program, you will have an array of type automobile that contains the cars in the dealership. The
array size will be 20 where you will use a named constant instead of a literal. This seems like very few cars
for a dealership, just assume that this is a dealership in Tokyo. The steps that you will perform will be
1. Read in the list of cars into the automobile array from a file, each line will contain one car entry, every
line will contain the make, model, year, color, and msrp in that order separated by a space and each
line will be terminated by an end of line character (you will use a command line argument to get the
file name and you will use a filestream to read through the file, the input file as well as some of the
source code can be find on the website)
2. Prompt the user to enter and attribute or q, then read in the input
(a) If the user entered an invalid attribute, output the error and ignore any other input on the line
(use cin.ignore(100, ) to ignore any input) and the repeat step 2
(b) If the user entered q, terminate the program
3. If the user entered a valid attribute (user entered Make, Model, Year, or Color), then read in
the search item and output all the cars that match the search item
4. If user entered list then read the next item on the line
(a) If the user entered Low, then output all the cars in sorted order according to their msrp from
high to low
1
(b) If the user entered High, then output all the cars in sorted order according to their msrp from
low to high
(c) If the user didnt enter Low or High then dont do anything and go back to step 2
5. Go back to step 2
Note: the user can enter an input using upper or lower case letters, make sure your program
can handle that
Example Run:
Enter search type or q to quit : make Honda
Make : Honda
Model : Civic
Year : 2005
Color : Silver
MSRP : 18840
Make : Honda
Model : Accord
Year : 2009
Color : White
MSRP : 23570
Make : Honda
Model : Fit
Year : 2015
Color : Blue
MSRP : 16190
Enter search type or q to quit : moDEL CHALLENGER
Make : Dodge
Model : Challenger
Year : 2018
Color : Red
MSRP : 26995
Enter search type or q to quit : yEaR 1986
Enter search type or q to quit : msrp 20000
Invalid Input ! Try again ! >:(
Enter search type or q to quit : origin germany
Invalid Input ! Try again ! >:(
Enter search type or q to quit : list HigH
2
Make : Kia
Model : Rio
Year : 2017
Color : Orange
MSRP : 13900
Make : Hyundai
Model : Accent
Year : 2008
Color : Yellow
MSRP : 14995
Make : Toyota
Model : Yaris
Year : 2011
Color : Red
MSRP : 15635
Make : Honda
Model : Fit
Year : 2015
Color : Blue
MSRP : 16190
Make : Hyundai
Model : Elantra
Year : 2015
Color : Silver
MSRP : 16950
Make : Ford
Model : Focus
Year : 2007
Color : Blue
MSRP : 17860
Make : Toyota
Model : Carolla
Year : 2007
Color : Red
MSRP : 18550
Make : Volkswagen
Model : Jetta
Year : 2005
Color : Silver
MSRP : 18645
Make : Honda
Model : Civic
Year : 2005
Color : Silver
MSRP : 18840
3
Make : Volkswagen
Model : Golf
Year : 2009
Color : Green
MSRP : 19895
Make : Volkswagen
Model : Beetle
Year : 2015
Color : Red
MSRP : 20220
Make : Hyundai
Model : Senata
Year : 2009
Color : Red
MSRP : 22050
Make : Toyota
Model : Camry
Year : 2005
Color : Yellow
MSRP : 23495
Make : Honda
Model : Accord
Year : 2009
Color : White
MSRP : 23570
Make : Ford
Model : Mustang
Year : 2016
Color : White
MSRP : 25585
Make : Chevrolet
Model : Camaro
Year : 2015
Color : Black
MSRP : 25905
Make : Dodge
Model : Challenger
Year : 2018
Color : Red
MSRP : 26995
Make : Ford
Model : Taurus
Year : 2004
Color : White
MSRP : 27595
4
Make : Dodge
Model : Charger
Year : 2017
Color : White
MSRP : 28495
Make : Chevrolet
Model : Corvette
Year : 2011
Color : Red
MSRP : 55495
Enter search type or q to quit : list car
Enter search type or q to quit : q
Input file:
Honda Civic 2005 Silver 18840
Dodge Challenger 2018 Red 26995
Volkswagen Beetle 2015 Red 20220
Toyota Camry 2005 Yellow 23495
Chevrolet Camaro 2015 Black 25905
Hyundai Accent 2008 Yellow 14995
Honda Accord 2009 White 23570
Ford Focus 2007 Blue 17860
Dodge Charger 2017 White 28495
Volkswagen Jetta 2005 Silver 18645
Hyundai Senata 2009 Red 22050
Kia Rio 2017 Orange 13900
Toyota Carolla 2007 Red 18550
Chevrolet Corvette 2011 Red 55495
Ford Mustang 2016 White 25585
Honda Fit 2015 Blue 16190
Ford Taurus 2004 White 27595
Toyota Yaris 2011 Red 15635
Volkswagen Golf 2009 Green 19895
Hyundai Elantra 2015 Silver 16950
Step by Step Solution
There are 3 Steps involved in it
Step: 1
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