Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Goal Practice the use of linked lists General remarks Keep all your testing code in submitted cpp files . For all the problems, ensure/add
Goal Practice the use of linked lists General remarks Keep all your testing code in submitted cpp files . For all the problems, ensure/add the proper memory allocation/deallocation (all instructions about memory are not necessarily mentioned in the instruction). . For all the problems, please use valgrind tool to confirm the proper memory management. Use the command: valgrind --tool-memcheck --leak-check=yes --show-reachable=yes --num-callers=20 --track-fds=yes ./01.0 where 01.o is the name of tested binary file Problem I. Linked Lists (20p) Write a program managing linked lists. Use single-linked list, forward-created. Each node describes a record info for a car. Node: int id string make int price int year Car *next // link to the next element In main () function, write a menu with the following options: 1. add car 2. remove car 5. exit - add new node to the end of the list. Automatically assign new id. - remove node, prompt for id of the car to remove Maintain a variable, where you store id numbers, so each newly added car will automatically receive new sequential id that was not assigned to any car before. Write the list of cars during each loop execution. . Provide proper deletion of the memory (both when option 2 is used and when option 5 is used) Sample output/operation CAR MANAGEMENT Car List: ------ Options: 1. Add car 2. Remove car 5. Exit Enter: 1 Enter make: Ford Enter price: 5000 Enter year: 2011 CAR MANAGEMENT Car List: 100 Ford Options: 1. Add car 2. Remove car 5. Exit Enter: 1 Enter make: GMC Enter price: 4500 Enter year: 2010 CAR MANAGEMENT Car List: 100 Ford 101 GMC Options: 1. Add car 2. Remove car 5. Exit Enter: 1 Enter make: Toyota Enter price: 7000 Enter year: 2013 CAR MANAGEMENT Car List: 100 Ford 101 GMC 102 Toyota Options: 1. Add car 2. Remove car 5. Exit 5000 5000 4500 5000 4500 7000 2011 2011 2010 2011 2010 2013 Enter: 2 Enter id of car to remove: 101
Step by Step Solution
★★★★★
3.35 Rating (155 Votes )
There are 3 Steps involved in it
Step: 1
The code is a program that manages linked lists of car records Each car record is stored in a node of the linked list which contains the information a...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