Question
Your task for this assignment is to implement a linked list data structure in C++. 1. Implement a transaction-based linked list data structure using C++.
Your task for this assignment is to implement a linked list data structure in C++.
1. Implement a transaction-based linked list data structure using C++. The program will be interactive. A transaction will be entered at the command line after a short prompt and output will be displayed on the console display. A batch of transactions in a file will be processed using redirection.
2. A linked list of names and ages will be created, updated and managed using Add, Delete and List transactions. Each name is added in uppercase format. The age must be in the range of 18 to 40. Transaction types will be processed as follows:
Add To add a name to the list, enter a transaction in the form of A, space, name, space, age. For example: A Paco 28. If the new name is not on the list and the age is valid, the name (in uppercase format) and age will be added such that names are in alphabetical order. When a new name is added, the message name added will be displayed. If the name is already on the list or if the age is out of range, the name will not be added, and the message name not added will be displayed.
Delete To delete a name and age from the list, enter a transaction in the form of D, space, name. For example: D Ling. If the name is not on the list, the message name not found will be displayed. If the name is on the list, the name and age will be removed and the message name deleted will be displayed.
List To display the names in the list, enter a transaction in the form of L. Each name in the list will be displayed with the respective age on a line by itself. Quit To terminate the program, enter a transaction in the form of Q.
In this assignment, predefined linked-list libraries are not allowed. All linked-list functions are to be defined within your program.
3. Here is sample dialogue of the running program: $ prog2 enter transaction: A Joan 24 name added enter transaction: A Manuel 35 enter transaction: A Abdul 50 name not added enter transaction: A Joan 21 name not added enter transaction: L JOAN 24 MANUEL 35 Enter transaction: Q
A sample file of transactions, such as prog2.dat, may contain the following: A Joan 24 A Manuel 35 A Abdul 50 A Joan 21 L Q Using redirection, the program will be run as follows: $ prog2 < prog2.dat The output produced will be similar to the output shown above with redirection. $ name added
NB: The question have been already answered, so I want my code to be unique with a lot of comments to explain what's going with each part of the program, thanks.
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