Question: Create a GUI for this particular project. You can use the lab 4 solution that youve submitted. Your GUI is completely up to you and

Create a GUI for this particular project. You can use the lab 4 solution that youve submitted.

Your GUI is completely up to you and should display all information that you find useful. It should be intuitive and informative.

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 ArrayList. Your students should be stored in an object called Student.

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

Here is my code, I am unable to get it to compile. I get an error at "public class StudentTest", it reads "class StudentTest is public, should be declared in a file name StudentTest.java".

How do I fix this compilation error and get the program to run properly?

import java.util.*; public class Student { private String firstName; private String lastName; private int sNumber; private String major; private double gpa; protected static int count; public Student(); { sNumber = 1234567 + count; } public Student(String firstName, String lastName, int sNumber, String major, double gpa) { this.firstName = firstName; this.lastName = lastName; this.sNumber = 1234567 + count; this.major = major; this.gpa = gpa; count++; } public String getFirstName() { return firstName; } public void setFirstName(String firstName) { this.firstName = firstName; } public String getLastName() { return lastName; } public void setLastName(String lastName) { this.lastName = lastName; } public int getSNumber() { return sNumber; } public String getMajor() { return Major; } public void setMajor(String major) { this.major = major; } public double getGpa() { return gpa; } public void setGpa(double gpa) { this.gpa = gpa; } @Override public String toString() { return String.format("%s %s %s %s %s", sNumber, firstName, lastName, major, gpa); } }

public class StudentTest { private static ArrayListlist = new ArrayList(); public static void main(String args) { Scanner sc = new Scanner(System.in); int choice = 0; do { displayMenu(); choice = sc.nextInt(); switch(choice) { case 1: addStudent(); break; case 2: findStudent(); break; case 3: deleteStudent(); break; case 4: displayStudents(); break; case 5: displayTotal(); break; case 6: break; default: System.out.println("Input error, try again"); } } while(choice != 6); System.out.printf(" Thanks for using the student directory, bye."); System.out.printf(" "); } private static void displayMenu() { System.out.println(" -----Menu-----"); System.out.println("Please choose an option."); System.out.printf(" 1. Add a student"); System.out.printf(" 2. Search for a student"); System.out.printf(" 3. Delete a student"); System.out.printf(" 4. Display all students"); System.out.printf(" 5. Display the total number of students"); System.out.printf(" 6. Exit "); System.out.println(); } private static void addStudent() { Scanner sc = new Scanner(System.in); System.out.printf(" Enter the student's first name."); String firstName = sc.nextLine(); System.out.printf(" Enter the student's last name."); String lastName = sc.nextLine(); System.out.printf(" Enter the student's major."); String major = sc.nextLine(); System.out.printf(" Enter the student's GPA."); double gpa = sc.nextDouble(); System.out.printf(" Added %s %s (Major: %s, GPA: %2f)", firstName, lastName, major, gpa); System.out.printf(" Returning to main menu."); Student s1 = new Student(firstName, lastName, 10, major, gpa); list.add(s1); } private static void findStudent() { Scanner sc = new Scanner(System.in); System.out.print("Find Student with number:"); int sNumber = sc.nextInt(); for(Student s: list) { if(sNumber == s.getSNumber()) { System.out.print("S" + s.getSNumber() + " " + s.getFirstName() + " " + s.getLastName + " "); System.out.println("Working"); } } } private static void deleteStudent() { Scanner sc = new Scanner(System.in); System.out.print("Delete student with sNumber S"); int sNumber = sc.nextInt(); for(Student s: list) { if(sNumber == s.getSNumber()) { System.out.print("S" + s.getSNumber() + " " + s.getFirstName() + " " + s.getLastName() + " has been deleted "); list.remove(s); } } } private static void displayStudents() { System.out.print("Students"); for(Student s : list) System.out.println("Name: " + s.getFirstName() + s.getLastName() + " Number: " + s.getSNumber + " Major: " + s.getMajor() + "Gpa: " + s.getGpa()); } private static void displayTotal() { System.out.print("Total number of students in the list: " + list.size()); System.out.println(" -----"); for(Student s : list) System.out.printf(s.toString()); } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!