(This class is so basic so no need to use advanced C++ codes) (We almost just ne
ID: 3773678 • Letter: #
Question
(This class is so basic so no need to use advanced C++ codes)
(We almost just need: Use of functions and re-use of functions whenever possible, Use of arrays.( no vectors) ,Use of files,Use of loops.)
- In this C++ program you are requested to implement a simple cars’ management system. The system should allow a user to perform a set of tasks through the following menu.
1-Add a car
2-Delete a car
3-Update car
4-Find car
5-List cars
6-Show statistics
7-Exit
The system has to keep looping until the user select the Exit option.
The system has to store cars’ data in a text file called “cars.txt”. This file will play the role of cars’ database.
Just an example:
Brand Model Price
Toyota Corolla 53000
Nissan Patrol 200000
Toyota Camry 80000
Nissan Sunny 42000
Chevrolet Impala 61000
Chevrolet Malibu 65000
….
The data has to be read from the file when the program start and stored back in the file when the program ends.
For each menu option you have to implement the following requirements:
Add a car
For each car you add you have to read the following details: ID, Brand name, Model name, price.
ID is a positive integer with exactly 4 digits.
price is an integer with only possible values.
The Brand name and model names are strings built out of the English alphabet characters excluding the space character (no spaces).
Each field you read for a cars has to be validated before it is accepted. Not that the car ID has to be unique among all cars.
For storing the list of all cars in your program, you can use parallel arrays or vectors.
Delete a car
For this option the user has to enter the ID of the car to delete. If the ID is not found, a message is displayed to tell the user that the car does not exist.
Update car
For this option the user has to enter the car ID to update. If the car exists, the system displays each field of the car and request from the user if he wants to update it. If the user answers yes the system requests the new value for the field.
Find car
For this option the user has to enter the car ID. The details of the car with the entered ID is displayed if it is found, otherwise a message is displayed to tell the user the car does not exist.
List cars
Displays cars by price in increasing order, each field is displayed in a separate column with a width of 10 characters.
Show statistics.
Displays for each brand of cars in the database, the number of cars of that brand.
Exit
Explanation / Answer
/* Testing Primitive Types (TestLiteral.cpp) */ #include using namespace std; int main() { char gender = 'm'; // char is single-quoted bool isMarried = true; // true(non-zero) or false(0) unsigned short numChildren = 8; // [0, 255] short yearOfBirth = 1945; // [-32767, 32768] unsigned int salary = 88000; // [0, 4294967295] double weight = 88.88; // With fractional part float gpa = 3.88f; // Need suffix 'f' for float // "coutRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.