Answer to Question #172329 in Java | JSP | JSF for Sawaira

Question #172329

How to Implement a Linked List class to store the following information about students:

Registration number of the student

Name of the student

CGPA of the student


1
Expert's answer
2021-03-16T23:52:46-0400
public class Student {
    private int registrationNumber;
    private String name;
    private double cgpa;

    public Student(int registrationNumber, String name, double cgpa) {
        this.registrationNumber = registrationNumber;
        this.name = name;
        this.cgpa = cgpa;
    }

    public int getRegistrationNumber() {
        return registrationNumber;
    }

    public String getName() {
        return name;
    }

    public double getCgpa() {
        return cgpa;
    }

    public void setRegistrationNumber(int registrationNumber) {
        this.registrationNumber = registrationNumber;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setCgpa(double cgpa) {
        this.cgpa = cgpa;
    }
}

public class LinkedList {
    private Node head;
    private Node tail;

    public boolean add(Student student) {
        Node node = new Node(student);
        if (head == null) {
            head = node;
        } else {
            tail.setNext(node);
        }
        tail = node;
        return true;
    }
}

public class Node {
    private Node next;
    private Student data;

    public Node(Student data) {
        this.data = data;
    }

    public Student getData() {
        return data;
    }

    public void setData(Student data) {
        this.data = data;
    }

    public Node getNext() {
        return next;
    }

    public void setNext(Node next) {
        this.next = next;
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

Assignment Expert
17.03.21, 07:12

Dear Sawaira, post a new question please

Sawaira
17.03.21, 07:02

Write client code, such that based on the registration number of the students, Retain only the record of the students whose GPA is greater than 1.3 and remove all the students record whose GPA is less than 1.3 previous program part 2

Leave a comment

LATEST TUTORIALS
New on Blog