Question
C Program A small car dealer would like to maintain information for the cars in stock. Each car was stored with the make and model,
C Program
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 C program dealer.c contains the car struct declaration, function prototypes, the main function, and the read_line function which is found below.
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 that 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, and color of all the cars.
4.) clearList: when the user exists the program, all the memory allocated for the linked list should be deallocated.
Note: Use read_line function included in the program for reading in make, model and color.
+include include includeStep 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