Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Student Registration Application\'\" This assignment aims to help you practice l

ID: 3701186 • Letter: S

Question

Student Registration Application'" This assignment aims to help you practice linked list data structure and basic linked list operations. Your main task in this assignment is to create a student registration system by using linked list data structure and basic linked list operations. In summary, as part of this assignment you need to write a pseudo code in Java that represents a student registration system. Your program needs to support the following functionalities. . One should be able to add a new student including their name and studentld to the registration system: . One should be able to search the registration system by the ld of the student One should be able to delete a student details by giving the student name; The main three methods you need to create are listed below: [Add student] You need to write a function called "addStudent" that asks user the details of the student they would like to add to their registration system which include their name and student id. After the user enters these details then this function adds this student to the registration system. Student ld is also unique so when you are entering a new student you need to check that this student does not exist [search student] You need to write a function called "SearchStudent" that asks the user to enter the student id and returns the name of the student. If the given id is not in the registration system, then this function needs to give an error message. (delete student] You ne of the student and then if that student exists in the registration system, this function deletes it, if it is not in the list then this function gives the right error message: · · ed to write a function called "deleteStudent" that takes the name . . Your program needs to also have the necessary functions to create and initialize registration list.

Explanation / Answer

import java.io.*;

import java.util.Scanner;

class node{

    int id;

    String name;

    node next;

    node(){

        name = "ABC";

        id = 0;

        next = null;

    }

   

    node(String n, int i){

        name = n;

        id = i;

    }

   

    public void setLink(node n)

    {

        next = n;

    }   

   

    public void setID(int d)

    {

        id = d;

    }  

   

    public void setName(String nm)

    {

        name = nm;

    }

   

    public node getLink()

    {

        return next;

    }   

   

    public int getID()

    {

        return id;

    }

   

    public String getName()

    {

        return name;

    }

}

class Student{

   

    node head;

    int size =0;

    Student(String n, int i){

        head = null;

        size = 0;

    }

    public int getSize()

    {

        return size;

    }

   

    public void addStudent()

    {

        node nptr = new node();   

        size++ ;   

        Scanner sc = new Scanner(System.in);

        System.out.println("Enter id of the Student: ");

        int newid = sc.nextInt();

        if(searchStudent(newid) == null){

        nptr.setID(newid);

        System.out.println("Enter name of the Student: ");

        nptr.setName(sc.next());

        } else {

            System.out.println("Student already exists");

        }

       

       

        if(head == null)

        {

            head = nptr;

        }

        else

        {

            nptr.setLink(head);

            head = nptr;

        }

    }

   

    String searchStudent(int i){

        

        node temp = new node();

        temp = head;

        while(temp.next != null){

            if(temp.id == i)

                return temp.name;

            else

                temp = temp.next;

        }

        System.out.println("Student record not found....returning null");

        return null;

    }

    public void deleteStudent(String name){

        node prev,curr;

        prev = head;

        curr = head.next;

       

        if(head == null){

            System.out.println("There are no student records found. List is empty");

            return;

        }

       

        while(curr.next == null){

           

            if(curr.name.equals(name)){

                prev.next = curr.next;

                curr = null;

                System.gc();

                System.out.println("Student record deleted");

                return;

            }

            else {

                prev = curr;

                curr = curr.next;

            }

        }

       

        System.out.println("Student record not found");

    }

   

}

public class Main

{

            public static void main(String[] args) {

           

            }

}