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

HELP NEEDED ASAP, will rate 100% coded in java input is 1111 PSY 765 801 3 CS 13

ID: 3703132 • Letter: H

Question

HELP NEEDED ASAP, will rate 100%

coded in java

input is

1111
PSY 765
801
3
CS 1340
501
4
1234
1357
Math 123
503
3

In this assignment, you will implement dynamic data structure such as Linked List Requirements At a local university each student takes a different number of courses, so the registrar has decided to use a linked list to store each student’s class schedule and an array to store the student ids. For example: CS 1340 5014 PSY 785 801 3 1234 Math 123 503 3 1357 Your program will read the data from input file in order to create student arrays as well as the linked list containing student records The student array or the linked list may be manipulated using insert, append or delete operations. For example an existing student may add or drop a course; a new student is added to the registration system or an existing one dropped from the system Provide operations for creating the original array, inserting a student’s initial class schedule, adding a course, dropping a course, adding or removing the student from the registration system Write the menu driven program to allow user to select various operations as discussed above, including exiting the program; output the linked list as well as the student array to the console. Note: your program must maintain a sorted array by student id as well as the linked list sorted by the course name.

HoMEWORK 8 StudentRegistration System Objectives Linked Lists Saving and Restoring Linked List using a text file SCENARIO In this assign ment, you will implement dyn amic data structure such as Linked List REQUIREMEN TS At a local university each stu denttakes a differentnumber of courses, so the registrar has decided to use a linkeld list to store each student's class schedule and an array to store the studentids. For example 0 cS 1340 5014 PSY 785 801 3 1234 1357 Math 123 503 3 Your program will read the data from input file in order to create stu dentarrays as well as the linked list containing stu dent records The stu dent array or the linked list may be manipulated u sing insert, append or delete operations. For example an existin g studentmay add or drop a course, a new stu dentis added to the registration system or an existin g on e dropped from the system Provide operations for creatin g the origin al array, inserting a student's initial class schedule, adding a course, droppin g a course, adding or removing the stu dentfrom the registration system Write the menu driven program to allow user to select various operation s as discussed above, including exitin g the program, outputthe linked list as well as the stu dentarray to the console Note: your program must maintain a sorted array by studentid as well as the linked list sorted by the course name

Explanation / Answer

import java.util.*;

import java.lang.*;

import java.io.*;

class Student

{   

int id;

String dept;

int studentcount;

int classes;

Student(int id,String dept,int studentcount,int classes)

{

this.id=id;

this.dept=dept;

this.studentcount=studentcount;

this.classes=classes;

}

public String toString()

{

return this.id + " " + this.dept +

" " + this.studentcount + " " + this.classes;

}

}

class Sortbyid implements Comparator<Student>

{

  

public int compare(Student a, Student b)

{

return a.id - b.id;

}

}

class Mainnn

{

public static void main (String[] args)

{

LinkedList<Student> list=new LinkedList<Student>();

list.add(new Student(1111,"PSY 765",801,3));

list.add(new Student(12342,"CS 1340",501,4));

list.add(new Student(1357,"MATH 123",503,3));

Scanner input=new Scanner(System.in);

System.out.println("1.Insert 2.sort 3.delete ");

int menu=input.nextInt();

System.out.println("Choose an option");

switch (menu)

{

case 1:

System.out.println("Unsorted");

for (int i=0; i<list.size(); i++)

System.out.println(list.get(i));

break;

case 2:

Collections.sort(list, new Sortbyid());

System.out.println(" Sorted by rollno");

for (int i=0; i<list.size(); i++)

System.out.println(list.get(i));

break;

case 3:

list.remove(1);

for (int i=0; i<list.size(); i++)

System.out.println(list.get(i));

break;

}

}}