Question: please i want the solution using C++ and beside each code please write a comment so I can easily understand the code 1. Create a

please i want the solution using C++ and beside each code please write a comment so I can easily understand the code  please i want the solution using C++ and beside each code
please write a comment so I can easily understand the code 1.
Create a new project called Lab4_ Link List Project2. 2. Create a
Node class & a LinkedList class, and program the tasks in the
main method. 3. Taskl: Write and test a method named swapFirstLast() which
swaps the data of first and last nodes in the linked list.
Note: If list is empty or contains only one node, your code
should display error message accordingly. Hint: Use following method header: void swapFirstLast()
{ } 4. Task2: Write and test a method named countEvenOddNodes() which

1. Create a new project called Lab4_ Link List Project2. 2. Create a Node class & a LinkedList class, and program the tasks in the main method. 3. Taskl: Write and test a method named swapFirstLast() which swaps the data of first and last nodes in the linked list. Note: If list is empty or contains only one node, your code should display error message accordingly. Hint: Use following method header: void swapFirstLast() { } 4. Task2: Write and test a method named countEvenOddNodes() which counts and displays number of even nodes as well as number of an odd nodes present in the linked list. Note: If list is empty, your code should display error message accordingly. Hint: Use following method header: void count EvenoddNodes () { int evenNodes = 0; int oddNodes = 0; cout Task4: deleteNodeAfter () "; //you will complete code here 8. When you run this program, it will display the following screen: Sample run 1: If the list is empty. How many values do you want to insert: 0 Printing All Nodes: The list is empty countNodes() Error: cannot count nodes (the list is empty) printEvenkodes) Error: cannot print even nodes (the list is empty) Taski: swapFirstLant() Error: cannot swap(the list has less than two nodes) AAAA Task2: countEvenOddNodes) The list is empty Number of Even nodes in the list is o Number of Odd nodes in the list 13 O Taxk3: addNodeAfter) Error: cannot add node after (the list is empty) V AA Task4: deleteNodeAfter) Erroz: cannot delete node after the list is empty) Samples run 2: * If the list has one element. 1) Printing an Nodes: 12, countNodes () Number of nodes in the linked list is 1 print venkodes() Printing Even Nodes. 12, V V Taski: swapFirstLast () Error: cannot swap(the list has less than two nodes) VVV Task2: countEvenoddNodest) Number of Even nodes in the list is 1 Number of Odd nodes in the list is o V V V Task3: addNodeAfter) Please enter the node data After which you want to add a new node: 30 Error: There is no node in the List with 30 AAA Task4: deleteNodeAfter() Please Enter the node data after which you want to delete a node: 30 Error: There is no node in the List with 30 How many values do you want to insert: 1 value 1: 12 12 was successfully inserted into the list. Printing All Nodes: 12, V countNodes) Number of nodes in the linked list is 1 printEvenNodes) Printing Even Nodes. 12. Taski: swapFirstLast () Error: cannot swap (the list has less than two nodes) Tank2: countEvenOddkodes () Number of Even nodes in the list is 1 Number of Odd nodes in the list is o Tasks: addNodeAftert) Please Enter the node data after which you want to add a new node: 12 New node have been added successfully! 12, 24, AAAA Task4: deletelodeAfte() Please Enter the node data after which you want to delete a node: 12 Node have been deleted successfully! 12, How many values do you want to insert: 1 value 1: 12 12 was wuccessfully inserted into the list. Printing All Nodes: 12, countNodes) Number of nodes in the linked list is 1 VV printEvenkodes) Printing Even Nodes. 12, Taski: swapFirstLast) Error: cannot swap(the list has less than two nodes) Task2: countEvenOddNodes() Number of Even nodes in the list is 1 Number of Odd nodes in the list 130 VVVV Task3: addNodeAfter) Please enter the node data after which you want to add a new node: 30 Error: There is no node in the list with 30 12, VVVV Task4: deleteNodeAfter() Please Enter the node data after which you want to delete a node: 12 No node can be deleted after this node as it is the last node in the list! 12, How many values do you want to insert: 2 value 1: 10 10 was successfully inserted into the list. value 2: 7 7 was successfully inserted into the list. Printing All Modes: 7, 10, countNodes) Number of nodes in the linked list is 2 printEvenNodes) Printing Even Nodes. 10. Taski: swapFirstLast() First and last element had been swaped successfully! 10, 7, Taska: countEvenOddNodes) Number of Even nodes in the 21st is 1 Numbez of Odd nodes in the list is 1 VYVY Task3: addNodeAfter) Please enter the node data after which you want to add a new node:7 New node have been added successfully! 10. 7. 14, Taskt: deleteNodeAfter) Please Enter the node data after which you want to delete a node: 10 Node have been deleted successfully! 10, 14, How many values do you want to insert: E value 1 : 12 12 was successfully inserted into the liss. value 2: 17 17 was successfully inserted into the 1.3. value 3: 10 10 was successfully inserted into the list. value : 50 50 was successfully inserted into the list. value 5: 10 10 already exists in the list. Duplicates are not allowed. value 5: 20 20 was successfully inserted into the list. value 6: 30 30 was recenfully inserted into the list. Printing All Nodes: 10, 12, 17, 20, 30, 50, countNodes) Number of nodes in the linked list 1.6 printEvenNodes) Printing Even Nodes. 10, 12, 20, 30, 50, Taski: swappiratLast!) First and last element had been waped successfully! 50, 12, 17, 20, 30, 10, Tank2: countEvenOddNodes Number of Even nodes in the list is s Number of Odd nodes in the list is 1 Tasks: addNodeAfter 1) Please enter the node data after which you want to add new node:20 New node have been added successfully! So, 12, 17, 20, 40, 30, 20, Task: deleteNodeafter Please enter the node data after which you want to delete a node: 12 Node have been deleted successfully! 50, 12, 20, 40, 30, 10

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!