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

Create a program that keeps track of specific information for Students. The info

ID: 3858417 • Letter: C

Question

Create a program that keeps track of specific information for Students. The information stored should be the following:

First Name, Last Name, Major, GPA, UIN, NetID, Age, Gender,

For this simple program we will only need to store 10 students in an LinkedList. Your students should be stored in an object called Student.You must create your own linked list and cannot use the LinkedList built into Java.

You should be able to add, display, sort (by any column you chose) and remove Students in the LinkedList.

This is the code I have, when I run the program, it prompts me to add 10 students. How do I make it so I can add, display, sort and remove students in the LinkedList?

import java.util.*;

class Student
{
String firstName, lastName, major, gender;
  
double gpa;
  
int UIN, netId, age;
  
Student next;
  
Student()
{
firstName = "";
lastName = "";
major = "";
gpa = 0.0;
UIN = 0;
netId = 0;
age = 0;
gender = "";
next = null;
}
  
Student(Student nextStudent)
{
firstName = "";
lastName = "";
major = "";
gpa = 0.0;
UIN = 0;
netId = 0;
age = 0;
gender = "";
next = nextStudent;
}
  
Student(String fname, String lname, String mjr, double gpaScore, int UINval, int netIdVal, int ageVal,
String gndr, Student nextStudent)
{
firstName = fname;
lastName = lname;
major = mjr;
gpa = gpaScore;
UIN = UINval;
netId = netIdVal;
age = ageVal;
gender = gndr;
next = nextStudent;
}
  
void getData(Scanner sc)
{
System.out.print(" Enter the first name: ");
firstName = sc.nextLine();
  
System.out.print(" Enter the last name: ");
lastName = sc.nextLine();
  
System.out.print(" Enter major: ");
major = sc.nextLine();
  
System.out.print(" Enter gpa: ");
gpa = sc.nextDouble();
sc.nextLine();
  
System.out.print(" Enter UIN: ");
UIN = sc.nextInt();
sc.nextLine();
  
System.out.print(" Enter NetId: ");
netId = sc.nextInt();
sc.nextLine();
  
System.out.print(" Enter age: ");
age = sc.nextInt();
sc.nextLine();
  
System.out.print(" Enter gender: ");
gender = sc.nextLine();
}
  
void display()
{
System.out.println("Student Details:");
System.out.println("First Name:" + firstName);
System.out.println("Last Name:" + lastName);
System.out.println("Major:" + major);
System.out.println("GPA:" + gpa);
System.out.println("UIN:" + UIN);
System.out.println("NetID:" + netId);
System.out.println("Age:" + age);
System.out.println("Gender:" + gender);
System.out.println();
}
};

public class Main
{
public static void main(String args[])
{
Student head = new Student();
Scanner sc = new Scanner(System.in);
int size = 0;
  
for(int i = 0; i < 10; i++)
{
System.out.println("Enter details for student " + (i + 1));
  
if(size == 0)
{
head = new Student(null);
}
else
{
head = new Student(head);
}
size++;
head.getData(sc);
}
  
for(int i = 0; i < 10; i++)
{
System.out.println(" Details for student" + (i + 1));
  
head.display();
head = head.next;
}
}
}

Explanation / Answer

import java.util.*;

class Student
{
String firstName, lastName, major, gender;
  
double gpa;
  
int UIN, netId, age;
  
Student next;
  
Student()
{
firstName = "";
lastName = "";
major = "";
gpa = 0.0;
UIN = 0;
netId = 0;
age = 0;
gender = "";
next = null;
}
  
Student(Student nextStudent)
{
firstName = "";
lastName = "";
major = "";
gpa = 0.0;
UIN = 0;
netId = 0;
age = 0;
gender = "";
next = nextStudent;
}
  
Student(String fname, String lname, String mjr, double gpaScore, int UINval, int netIdVal, int ageVal,
String gndr, Student nextStudent)
{
firstName = fname;
lastName = lname;
major = mjr;
gpa = gpaScore;
UIN = UINval;
netId = netIdVal;
age = ageVal;
gender = gndr;
next = nextStudent;
}
  
void getData(Scanner sc)
{
System.out.print(" Enter the first name: ");
firstName = sc.nextLine();
  
System.out.print(" Enter the last name: ");
lastName = sc.nextLine();
  
System.out.print(" Enter major: ");
major = sc.nextLine();
  
System.out.print(" Enter gpa: ");
gpa = sc.nextDouble();
sc.nextLine();
  
System.out.print(" Enter UIN: ");
UIN = sc.nextInt();
sc.nextLine();
  
System.out.print(" Enter NetId: ");
netId = sc.nextInt();
sc.nextLine();
  
System.out.print(" Enter age: ");
age = sc.nextInt();
sc.nextLine();
  
System.out.print(" Enter gender: ");
gender = sc.nextLine();
}
  
void display()
{
System.out.println("Student Details:");
System.out.println("First Name:" + firstName);
System.out.println("Last Name:" + lastName);
System.out.println("Major:" + major);
System.out.println("GPA:" + gpa);
System.out.println("UIN:" + UIN);
System.out.println("NetID:" + netId);
System.out.println("Age:" + age);
System.out.println("Gender:" + gender);
System.out.println();
}
};

public class Main
{
public static void main(String args[])
{
Student head = new Student();
Scanner sc = new Scanner(System.in);
size = sc.nextInt();
  
for(int i = 0; i < size; i++)
{
System.out.println("Enter details for student " + (i + 1));
  
if(size == 0)
{
head = new Student(null);
}
else
{
head = new Student(head);
}
size++;
head.getData(sc);
}
  
for(int i = 0; i < 10; i++)
{
System.out.println(" Details for student" + (i + 1));
  
head.display();
head = head.next;
}
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote