Use arrays, files, searching arrays, manipulating array contents, characters, and strings.
You are asked to implement a car ordering system for Bobcats Auto Dealership. This dealership is brand new and only sells one brand of cars with three different models. However, a buyer can add options if they choose.
Write a C++ program that allows the user to order a single car with different options. All the options available will be stored in a file called options.txt along with their cost. You may assume that the file will not contain more than 30 options. The user should be able to select the car model, display options and prices, add options, remove options, or cancel the order. Allow the user to see all the available options and their prices. The program should always display the car model, cost, and the options ordered so far. If the user has not selected a car model, then an error message should be displayed indicating that the order has not started yet (e.g. NO MODEL SELECTED). A user should not be able to add more than 6 options to the car.
The base prices of the three models: E ($10,000.00), L ($12,000.00), and X ($18,000.00).
Implement the following menu options in separate functions:
- Select a model (E, L, X)
The user should enter either E, L, or X (either in lower or upper case). If the wrong character is entered, the user should be prompted repeatedly until the user enters a valid model. Update the order information after this selection.
- Display available options and prices List all the options 3 per line. See below.
- Add an option
The user should enter an option such as DVD System, 10 Speakers, etc. The option entered must be one of the options available. If its not, the user should be prompted repeatedly until the user enters a valid option or enter cancel. After the selection, the order information should be updated. (see sample input/output below). Duplicate options should not be allowed.
- Remove an option
Allow the user to remove one of the option from the list of options added earlier. Update the order information. If the option name is not in the list of options, then it should be ignored.
- Cancel order
Start over. Update the order information.
- Quit
Hints:
- Use an array/vector to store all the options along with an integer for the number of options read.
- Use an array/vector to store all the options prices.
- Use an array/vector of strings for the options added along with an integer for the number of options ordered.
- Write a function to convert a string to lowercase for comparison.
- Write a function that returns true if an option is valid
Sample input/output:
NO MODEL SELECTED
- Select a model (E, L, X)
- Display available options and prices
- Add an option
- Remove an option
- Cancel order
- Quit
Enter choice: 3
NO MODEL SELECTED
- Select a model (E, L, X)
- Display available options and prices
- Add an option
- Remove an option
- Cancel order
- Quit
Enter choice: 2
Prices for model E, L, & X: $10000.00, $12000.00, $18000.00
Available Options
Leather Seats ($5000) | DVD System ($1000) 10 Speakers ($800) |
Navigation System($1400) | CarPlay ($500) Android Auto ($500) |
Lane Monitoring ($2000) | 3/36 Warranty ($800) 6/72 Warranty ($999) |
Dual Climate ($1500) | Body Side Molding($225) Cargo Net ($49) |
Cargo Organizer ($87) | 450W Audio ($700) Heated Seats($1000) |
NO MODEL SELECTED
- Select a model (E, L, X)
- Display available options and prices
- Add an option
- Remove an option
- Cancel order
- Quit
Enter choice: 1
Enter the model (E, L, X): l
Model: L, $12000.00, Options: None
- Select a model (E, L, X)
- Display available options and prices
- Add an option
- Remove an option
- Cancel order
- Quit
Enter choice: 3
Enter option: 450w aUdIO
Model: L, $12700.00, Options: 450W Audio
- Select a model (E, L, X)
- Display available options and prices
- Add an option
- Remove an option
- Cancel order
- Quit
Enter choice: 3
Enter option: carplay
Model: L, $13200.00, Options: 450W Audio, CarPlay
- Select a model (E, L, X)
- Display available options and prices
- Add an option
- Remove an option
- Cancel order
- Quit
Enter choice: 4
Enter option to remove: carplay
Model: L, $12700.00, Options: 450W Audio
Reviews
There are no reviews yet.