Statement Purpose: Purpose of this Lab is to familiarize the students with writing simple Java programs using Linked List. The students are given small tasks related to Linked List which they complete during the lab session under the supervision of the lab instructor. This helps them understand the concepts well which they learnt in their lectures. Activity Outcomes: The students will learn how to write methods related to some actions performed on Linked List. They will understand how to write simple methods to swap the data of first and last nodes in the linked list count and display number of even nodes and also number of odd nodes present in the linked list add a new node after some specific node of the linked list delete a node after some specific node of the linked list Practice Activity with Lab Instructor: (10 Minutes) Code for countNodes( Method The method countNodes counts the number of nodes in the linked list and returns it's to the calling main() method. //This method is called from main() method int countNodes () { Node* helpPtr = head; int count = 0; while (helpPtr != null) { count++; helpPtr = helpPtr->next(); return count; Code for printEven Nodes( Method The method printEven Nodes ( print all even nodes in the linked list. void printEvenNodes () { Node* helpPtr = head; while (helpPtr != null) { if (helpPtr->data $ 2 == 0) { cout data next; LAB EXERCISE: (70 Minutes) 1. Create a new project called Lab4_LinkListProject2. 2. Create a Node class & a LinkedList class, and program the tasks in the main method. 3. Task 1: 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 swapFirst Last() { 4. Task2: Write and test a method named count EvenOddNodes() 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 countEvenOddNodes () { int evenNodes = 0; int oddNodes = 0; cout Task 4: 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: Printing All Nodes: The lat tempty count. Modest Error: cannot count nodes the list is empty printEverodes) Error: Cannos prist even nodes the list is espeys Taski: wapFirstlast) Error: Cannot swap the list has less than to nodes) Task 2: count EvenoddNodes) The list is empty Number of Even nodes in the list is o Number of Odd modeshe 1st 10 Tasks: addNodeafter Error: cannot add node after the list is empty Taak: deleteMode After Error: cannot delete node after the list is empty Samples run 2: * If the list has one element. Printing All Modes: 12 countNodes) Number of nodes in the linked list is 1 printEvenodes) Printing Even Nodes. Taski: swapFirstLast) Error: cannot swap the list has less than the nodes) Task2: count Evenoddiodes) Number of Even nodes in the list is 1 Number of Odd nodes in the list 10 Task 3: 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 Taak: deletelodenitez) 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. countNodest) Number of nodes in the linked list is 1 printEvenkodes) Printing Even Nodes. Taski: swapFiestlast) EEEE: Cannot swap the list has less than to nodes) Task2: count EvenOddNodes) Number of Even nodes in the list is 1 Number of Odd nodes in the list is o Task 3: addNodeAfter) Please Enter the node data after which you want to add a new node: 12 New node have been added successfully! 12, 24, Task: deleteNodeAfter) 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 successfully inserted into the list. Printing All Nodes: 12, countNodes() Number of nodes in the linked list is 1 printEvenNodes () Printing Even Nodes. 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 is o 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. 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. Sample run 3: If the user inserts 2 elements 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 Nodes: 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, Task2: countEvenOddNodes () Number of Even nodes in the list is 1 Number of Odd nodes in the list is 1 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, Task4: deleteNodeAfter() Please Enter the node data after which you want to delete a node: 10 Node have been deleted successfully! 10, 14, Sample run 4: If the user inserts more than 2 elements How many values do you wat te insert 6 value 1: 12 12 was successfully inserted into the list. value 2 : 17 17 was successfully inserted into the list. value 3:10 10 was successfully inserted into the list. value 4: 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 successfully inserted into the list Printing All Nodes: 10, 12, 17, 20, 30, 50, countNodes) Number of nodes in the linked list 16 printEvenkodes() Printing Even Nodes. 10, 12, 20, 30, 50, Taski: wapistlast) First and last element had been waped successfully! 50, 12, 17, 20, 30, 10, Task2: countEvenOddNodes) Number of Even nodes in the list is 5 Number of Odd nodes in the list is 1 Taak3: addNodeAfter Please Enter the node data after which you want to add a new node:20 New node have been added successfully! 50, 12, 17, 20, 40, 30, 10, Task4: 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