Question
1. (60 points) Modify Project 8 (Listed below, create based on specifications) so that the program is split into three source files and two header
1. (60 points) Modify Project 8 (Listed below, create based on specifications) so that the program is split into three source files and two header files.
1) Put all functions related to operations on the list of cars into car.c. 2) Create a header file named car.h that contains struct car declaration and prototypes for the functions in car.c. The header file should enclose the contents of the header file in an #ifndef-#endif pair to protect the file. 3) Put the read_line function in a separate file named readline.c. 4) Create a header file named readline.h that contains a prototype for the read_line function. The header file should enclose the contents of the header file in an #ifndef-#endif pair to protect the file. 5) dealer.c contains the main function. 6) Include appropriate header files in the source files. 2. (40 points) Write a makefile to build the program on student cluster. The makefile should contain the following rules: 1) Build readline.o by compiling readline.c 2) Build car.o by compiling car.c 3) Build dealer.o by compiling dealer.c 4) Build dealer by linking readline.o, car.o, and dealer.o Each rule should include the name of the target file, dependencies among files, and the command to be executed. The makefile should name the executable file for the program dealer.
(Project 8)
A small car dealer would like to maintain information for the cars in stock. Each car was stored with the make and model, color, manufacture year, city mpg, highway mpg, and quantity. The program dealer.c contains the car struct declaration, function prototypes, and the main function. Complete the function definitions so it uses a dynamically allocated linked list to store the cars. The following functions should be completed:
1. append_to_list: ask the user to enter a cars make, model, color, manufacture year, city mpg, highway mpg, and quantity (in the exact order), then add the car to the end of the linked list. a. It should check whether the car has already existed by make, model, color, and manufacture year. If so, the function should print a message and exit. b. If the car does not exist, allocate memory for the player, store the data, and append the car to the end of the linked list. c. If the list is empty, the function should return the pointer to the newly created car. d. Otherwise, add the car to the end of the linked list and return the pointer to the linked list. 2. find_car: search by make and model, print the cars color, manufacture year, city mpg, highway mpg, and quantity. Print all cars that match the make and model. If the make and model is not found, print a message.
3. printList: print the make, model, and manufacture year, color, city mpg, highway mpg, and quantity of all the cars.
4. clearList: when the user exists the program, all the memory allocated for the linked list should be deallocated.
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