Question: / * * * * * * * * * * * * * * * * * * * * * * * *
Author:
Date:
Purpose: Starter code for homework you should udpate this description
#include
#include "Dealership.h
GIVEN mostly given to you you will need to modify this code to add the car
to the Dealership object instead of just printing the information to the screen
void readstring filename, Dealership & carDealership
Attempt to open specified file
ifstream dinfilename;
Check if file was opened successfully
if dinfail
cout "Error opening file filename endl;
exit;
Declare variables to read into
string name, condition;
int price, year;
float mileage;
Read in header line from file, throw away
getlinedin name;
Read in all movies from file
while din.eof
din name price condition mileage year;
this is provided for error checking to make sure you are reading in the file of cars
after you know you are, you will comment this line out and just add the car to the
Dealership object array using a method found in the Dealership class
cout name price condition mileage year endl;
Add car to Dealership object array you will be adding code here!!
you do NOT need to add code above this line
Close input file
din.close;
GIVEN Function to print menu to console
void printMenu
cout t Add a car" endl;
cout t Filter available cars by condition" endl;
cout t Filter available cars by maximum amount of mileage" endl;
cout t Filter available cars by a range of years inclusive endl;
cout t Find the least expensive car available in the inventory" endl;
cout t Print all cars" endl;
cout t Exit" endl;
GIVEN get the user's choice from the menu
int getUserChoice
Declare variable to store user choice, prompt for input, and store input
int choice;
cout "Enter choice ;
cin choice;
cout endl;
Check if input is valid
if choice choice
cout "Invalid choice. Try again." endl;
return getUserChoice;
Return user choice
return choice;
int main
Display welcome message
Create Dealership object using default constructor, call read function found above
Print menu and get user choice
while user's choice is not to quit
switch statement between the options
goodbye message
return ;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
