In JAVA Create a GUI for this particular project. Your GUI is completely up to y
ID: 3820271 • Letter: I
Question
In JAVA
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.
Hint: To make your life easier take your previous lab solution and add a menu bar instead of adding a lot of new items.
Explanation / Answer
Student.java
import java.util.ArrayList;
public class Student {
private String firstName;
private String lastName;
private String major;
private double gpa;
private int uin;
private int netID;
private int age;
private char gender;
private ArrayList<Student> list;
/***
*
* @param firstName
* @param lastName
* @param major
* @param gpa
* @param uin
* @param netID
* @param age
* @param gender
*/
Student(String firstName, String lastName, String major, double gpa,
int uin, int netID, int age, char gender) {
this.firstName = firstName;
this.lastName = lastName;
this.major = major;
this.gpa = gpa;
this.uin = uin;
this.netID = netID;
this.age = age;
this.gender = gender;
}
Student() {
list = new ArrayList<Student>(10);
}
public String toString() {
return "First Name: " + firstName + " LastName: " + lastName
+ " Major: " + major + " GPA: " + gpa + " UIN: " + uin
+ " NetID: " + netID + " Age: " + age + " Gender: "
+ gender;
}
/***
*
* @param st
*/
public void add(Student st) {
list.add(st);
}
/***
*
* @param st
*/
public void remove(Student st) {
for (int i = 0; i < list.size(); i++) {
if (st.uin == list.get(i).uin) {
list.remove(i);
}
}
}
/***
*
* @param args
*/
public static void main(String args[]) {
Student student = new Student();
System.out.println("Load Student into list");
student.load();
for (int i = 0; i < student.list.size(); i++) {
System.out.println(student.list.get(i).toString());
System.out.println("-----------------------------");
}
System.out.println("Add Student into list");
Student st = new Student("Loki", "Paul", "MA", 3, 368, 1254, 34, 'M');
System.out.println("-----------------------------");
System.out.println(st.toString());
System.out.println("-----------------------------");
student.list.add(st);
System.out.println("Remove Student with 345 UID");
student.list.remove(st);
System.out.println(" Student list After Remove");
for (int i = 0; i < student.list.size(); i++) {
System.out.println(student.list.get(i).toString());
System.out.println("-----------------------------");
}
}
public void load() {
list.add(new Student("Nike ", "Anderson", "B.A", 4.0, 131, 13, 23, 'M'));
list.add(new Student("Mike ", "Anderson", "B.A", 4.0, 131, 13, 27, 'M'));
list.add(new Student("Remesey ", "Anderson", "B.A", 4.0, 131, 13, 27,
'F'));
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.