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

Create a GUI for this particular project. Your GUI is completely up to you and s

ID: 3856623 • Letter: C

Question

Create a GUI for this particular project. 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.

Explanation / Answer

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);
}
}

import java.util.*;
public class StudentTest
{
private static ArrayList<Student> list = new ArrayList<Student>();
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, please try again");
}
} while (choice != 6);
System.out.printf(" Thanks for using the student directory. Goodbye! ");
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. Find a student.");
System.out.printf(" 3. Delete a student.");
System.out.printf(" 4. Display all students.");
System.out.printf(" 5. Display 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(" What's the student's first name? ");
String firstName = sc.nextLine();
System.out.printf(" What's the student's last name? ");
String lastName = sc.nextLine();
System.out.printf(" What's the student's major? ");
String major = sc.nextLine();
System.out.printf(" What's 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 Students in List : "+list.size());
System.out.println(" ------------------------------");
for(Student s : list)
System.out.printf(s.toString()); }
}