Write a Java program that will maintain the registration of

Write a (Java) program that will maintain the registration of a (very small, for this project) college, using the Student and Course Classes that you have already written.
The program should be able to:
•   Load the current registration from the text file that you saved for the Warm-Up project and save the student data into a sorted array for the registration.
•   Add a new student to the registration.
•   Delete a current student from the registration.
•   Search for a student by name and display the student’s information on the monitor.
•   Search for a student by name and add a course/grade to the student’s current course list.
•   Search for a student by name and delete a course/grade from the student’s current course list.
•   Display the current registration.
•   Save the updated registration to a text file.
Your program should include a menu for the user that will use each of the above methods. Your main program should not access the array directly – only through the sorted array methods.

Student.class setup: http://pastebin.com/UY9Lspcw
Couse.class setup: http://pastebin.com/j6XHtHyP

And the text file I have to read is setup like this:
Jones,Mary,903452
4342,2.5,A      
3311,4,B+      
-999          
6.5,3.569      
Martin,Joseph,312345  
4598,3,C      
1122,3,A-      
2467,4,A      
-999          
10,3.31

How can I read the text file and put it into a regular array WITHOUT USING an arraylist? Thanks.

Solution

public class Course {

    private String name; //Name of course

    private Student[] students; //Declare array

    private int capacity; //Number of students allowed in course

    private int currentEnrollment; //number of students enrolled

    private static int numberOfCourses; //Number of courses created so far

    

    //Constructor

    Course(String n, int cap) {

        name = n;

        capacity = cap;

        students = new Student[capacity] //Create array

     }

    

    //Get and set methods

    String getName() {

        return name;

    }

    public void setName(String newName) {

        name = newName;

    }

    int getCapacity() {

        return capacity;

    }

    public void setCapacity(int newCapacity) {

        capacity = newCapacity;

    }

    

    //Method to add a student (s) to the course and return true if added and false if not

    public static boolean addStudent(Student s) {

        if (currentEnrollment >= capacity) { //See if course has room

            currentEnrollment++;

            return true;

        }

        else {

            return false;

        }

    }

    //Method to remove student from a class

    public static void removeStudent(Student s) {

        currentEnrollment--;

    }

}

public class Course {

    private String name; //Name of course

    private Student[] students; //Declare array

    private int capacity; //Number of students allowed in course

    private int currentEnrollment; //number of students enrolled

    private static int numberOfCourses; //Number of courses created so far

    

    //Constructor

    Course(String n, int cap) {

        name = n;

        capacity = cap;

        students = new Student[capacity] //Create array

     }

    

    //Get and set methods

    String getName() {

        return name;

    }

    public void setName(String newName) {

        name = newName;

    }

    int getCapacity() {

        return capacity;

    }

    public void setCapacity(int newCapacity) {

        capacity = newCapacity;

    }

    

    //Method to add a student (s) to the course and return true if added and false if not

    public static boolean addStudent(Student s) {

        if (currentEnrollment >= capacity) { //See if course has room

            currentEnrollment++;

            return true;

        }

        else {

            return false;

        }

    }

    //Method to remove student from a class

    public static void removeStudent(Student s) {

        currentEnrollment--;

    }

}

Write a (Java) program that will maintain the registration of a (very small, for this project) college, using the Student and Course Classes that you have alrea
Write a (Java) program that will maintain the registration of a (very small, for this project) college, using the Student and Course Classes that you have alrea
Write a (Java) program that will maintain the registration of a (very small, for this project) college, using the Student and Course Classes that you have alrea
Write a (Java) program that will maintain the registration of a (very small, for this project) college, using the Student and Course Classes that you have alrea

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site