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

JAVA HELP NEEDED ASAP.. I need this program to use an array to hold a students I

ID: 3565389 • Letter: J

Question

JAVA HELP NEEDED ASAP.. I need this program to use an array to hold a students ID number, and have that students ID number be linked to a linked list of school courses. Courses will have course name (CSC236), section (23), and course credit (4). I have been at it for days but cannot seem to get it to link correctly. please excuse my formating as I have been at it for days and my brain has turned to mush..The offical instructions list below. (WE HAVE TO CREATE OUR OWN LINKED LIST, WE CANNOT USE JAVA'S LINKED LIST. I orginal started with a seperate class for course but gave that up.

Each student at Middlesex County College takes a different number of courses, so the registrar has decided to use linear linked lists to store each student's class schedule and an array to represent the entire student body These data show that the first student (ID: 1111) is taking section 1 of CSC162 for 3 credits and section 2 of HIS101 for 4 credits; the second student is not enrolled; the third student is enrolled in CSC236 section 4 for 3 credits. Write a class for this data structure. Provide methods for creating the original array, inserting a student's initial class schedule, adding a course, and dropping a course. Include a menu-driven program that uses the class.

*******************COURSE NODE

class CourseNode
    {
        String courseName;
  int section;
       int credit;
        CourseNode next;

        public CourseNode()
        {
          courseName = " ";
   section = 0;
        credit = 0;
         next = null;

        }

        public CourseNode(String courseName, int section, int credit, CourseNode next)
        {
   this.courseName = courseName;
   this.section = section;
   this.credit = credit;
   this.next = next;
        }


  public String getCourse()
  {
   String str = "CourseName:"+courseName+" Section:"+section+" Credits:"+credit;
      return str;
  }

  public void setCourse(String courseName, int section, int credit, CourseNode next)
  {
   this.courseName = courseName;
   this.section = section;
   this.credit = credit;
   this.next = next;
  }

  public CourseNode getNext()
  {
   return next;
  }

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

        public String toString()
        {
   String str = "CourseName:"+courseName+" Section:"+section+" Credits:"+credit;
      return str;
        }

    }

************STUDENT LIST

public class StudentList extends CourseNode
{
protected CourseNode head;
private int sID;
private CourseNode[] student = new CourseNode[10000]; // Holds the data of each node
private String courseName;
private int section;
    private int credit;
    //private CourseNode[] next = new CourseNode[10000]; // Holds the 'next' index of each node


/**
  StudentList constructor creates the max students permitted to enroll (99,000).
*/
    public StudentList()
    {
   sID = 0;
   courseName = " ";
    section = 0;
   credit = 0;

        head = null;

    }
    public StudentList(int sID, String courseName, int section, int credit)
    {
  this.sID = sID;
  this.courseName = courseName;
  this.section = section;
  this.credit = credit;
  CourseNode student[] = new CourseNode[10000];
  student[sID].setCourse(courseName, section, credit, null);


    }
//Returns the node that is at the head of the linked list
public CourseNode getListStart()
{
    return head;
}


/*


//Adds a courseNode to the beginning of the list
public void addCourse( )
{
  head = getListStart();
    head = new CourseNode(course, head);       //Creates a new node pointing to the head and sets the head of the new course to the new node

}


//Checks if if course exists, if it does it removes course.
public boolean dropCourse(T course)
{
    if(head==null)          //Returns false if there are no courses
        return false;

    if(head.getCourse().equals(course))   //If the head Node's data is [target]
    {
        head = head.getNext();      //Make the next Node the head
        return true;            //Returns true, found [target]
    }

    CourseNode pointer = head;          //Sets temporary Node, pointer to the same value as head

    while(pointer.getNext() != null)     //Loops until the next Node contains no value
    {
        pointer = pointer.getNext();      //Pointer continues down linked list

        if(pointer.getNext().getCourse().equals(course))   //If the next node's data is matches target course
        {
            pointer.setNext(pointer.getNext().getNext());     //Sets current Node's link to the next Node's link, by passing the next Node
            return true;            //Returns true, found [target]
        }
    }
    return false;           //Returns false, [target] not found
}
*/


}

**********************Demo

public class CourseDemo
{

public static void main(String[] args)
{

        int sID = 0;


        Scanner keyboard = new Scanner(System.in);



  System.out.println("All Student IDs must be 4 digits in length. Example: 1111.");
  System.out.println("All Course names should be 3 letters and 3 digits. Example: CSC236");
  System.out.println("All Course sections should be 2 digits in length. Example: 64");
  System.out.println("No Course is permitted to have more then 4 credits without authorization from Dean Johnson. Example: 4");
  System.out.println(" Please choose from the below options:");
        System.out.println("1-Add a course. 2-Drop a course. 3-Check current courses that student is enrolled in. 4-Exit.");
  int choice = keyboard.nextInt();

        while(choice != 4)
        {
        if(choice == 1)
            {
                System.out.println("Enter student ID to add a course: ");
                sID = keyboard.nextInt();
                keyboard.nextLine();
                System.out.println("Enter Course Name: ");
                String courseName = keyboard.nextLine();
                System.out.println("Enter Section Number: ");
                int section = keyboard.nextInt();
                System.out.println("Enter Credits: ");
                int credit = keyboard.nextInt();
                StudentList student = new StudentList(sID, courseName, section, credit);


            }

            else if(choice == 2)
            {
                System.out.println("Enter student ID to drop a course: ");
                sID = keyboard.nextInt();
                keyboard.nextLine();
                System.out.println("Enter Course Name: ");
                String courseName = keyboard.nextLine();

            }
/*
            else if(choice == 3)
            {
                System.out.println("Enter student ID number to see current enrolled courses: ");
                sID = keyboard.nextInt();
                System.out.println(" Student " + sID +" is enrolled in the following classes: ");

                CourseNode pointer = studentID[sID].getListStart();
                Object tempCourse;
                while(pointer != null)
                {
     tempCourse = pointer.getCourse();
                    System.out.println(pointer.getCourse());
                    pointer = pointer.getNext();
         }
            }


            else if(choice == 4)
            {
                System.exit(1);
            } */

            else
            {
    System.out.println("Invalid choice entered. Please try again.");
   }

   keyboard.nextLine();
            System.out.println(" Please choose from the below options:");
        System.out.println("1-Add a course. 2-Drop a course. 3-Check current courses that student is enrolled in. 4-Exit.");
            choice = keyboard.nextInt();
        }
    }
}

2. Each student at Middlesex County College takes a different number of courses, so the registrar has decided to use linear linked lists to store each student?s class schedule and an array to represent the entire student body. A portion of this data structure is shown below: These data show that the first student (ID: 1111) ?s taking section 1 of CSC162 for 3 credits and section 2 of H1S101 for 4 credits; the second student is not enrolled; the third student is enrolled in CSC236 section 4 for 3 credits. Write a class for this data structure. Provide methods for creating the original array, inserting a student?s initial class schedule, adding a course, and dropping a course. Include a menu-driven program that uses the class.

Explanation / Answer

import java.util.*; import java.io.*; public class Model { private ArrayList students; private ArrayList modules; private Module moduleLink; public Model(){ students = new ArrayList(); modules = new ArrayList(); } public void runTests() throws FileNotFoundException{ System.out.println("Beginning program, the ArrayList of students will now be loaded"); loadStudents("studentlist.txt"); System.out.println("Load attempted, will now print off the list"); printStudents(); System.out.println("The module list will now be loaded and printed"); loadModules("moduleslist.txt"); printModules(); System.out.println("Modules printed, ArrayList assosciation will commence"); } public void printStudents(){ for(Student s: students){ System.out.println(s.toString()); } } public void printModules(){ for(Module m: modules){ System.out.println(m.toString()); } } public void loadStudents(String fileName) throws FileNotFoundException{ Scanner infile =new Scanner(new InputStreamReader (new FileInputStream(fileName))); int num=infile.nextInt();infile.nextLine(); for (int i=0;i