Create a program that keeps track of specific information fo

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 and remove Students in the ArrayList.

You will submit 2 files for grading: Driver.java and Student.java

I can only use:

import java.util.ArrayList;
import java.util.Scanner;

Solution

// Student.java

public class Student{
   public String firstName;
   public String lastName;
  
   String major;
   double gpa;
   int uin;
   int netId;
   int age;
   String gender;
   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 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;
   }
   public int getUin() {
       return uin;
   }
   public void setUin(int uin) {
       this.uin = uin;
   }
   public int getNetId() {
       return netId;
   }
   public void setNetId(int netId) {
       this.netId = netId;
   }
   public int getAge() {
       return age;
   }
   public void setAge(int age) {
       this.age = age;
   }
   public String getGender() {
       return gender;
   }
   public void setGender(String gender) {
       this.gender = gender;
   }
   public String toString(){
       String str = \"Name: \" + lastName + \", \" + firstName;
       str += \"\ Major: \" + major;
       str += \"\ GPA: \" + gpa;
       str += \"\ UIN: \" + uin;
       str += \"\ NetID: \" + netId;
       str += \"\ Age: \" + age;
       str += \"\ Gender: \" + gender + \"\ \";
       return str;
   }
   public Student(String firstName, String lastName, String major, double gpa, int uin, int netId, int age, String 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;
   }
}

// Driver.java

import java.util.ArrayList;
import java.util.Scanner;

public class Driver{
   static void display(ArrayList<Student> students){
       for(int i = 0; i < students.size(); i++){
           System.out.println(students.get(i));
       }
   }
   static int search(ArrayList<Student> students, int uin){
       for(int i = 0; i < students.size(); i++){
           if(students.get(i).getUin() == uin) return i;
       }
       return -1;
   }
   public static void main(String args[]){
       ArrayList<Student> students = new ArrayList<Student>();
       int choice;
       Scanner in = new Scanner(System.in);
       String fn, ln, m, gender;
       double g;
       int uin, nid, age;
       while(true){
           System.out.print(\"1. Add a student\ 2. Remove a student\ 3. Print\ 4. Exit\");
           choice = in.nextInt();
          
           switch(choice){
           case 1:
               System.out.print(\"Enter the first name: \");
               fn = in.nextLine();
               System.out.print(\"Enter the last name: \");
               ln = in.nextLine();
               System.out.print(\"Enter the major: \");
               m = in.nextLine();
               System.out.print(\"Enter the GPA: \");
               g = in.nextInt();
               System.out.print(\"Enter the uin: \");
               uin = in.nextInt();
               System.out.print(\"Enter the NetID: \");
               nid = in.nextInt();
               System.out.print(\"Enter the age: \");
               age = in.nextInt();
               System.out.print(\"Enter the gender: \");
               gender = in.nextLine();
               Student temp = new Student(fn, ln, m, g, uin, nid, age, gender);
               students.add(temp);
               break;
           case 2:
               System.out.print(\"Enter the uin to delete: \");
               uin = in.nextInt();
               int index = search(students, uin);
               students.remove(index);
               break;
           case 3:
               display(students);
           case 4:
               return;
           }
       }
   }
}

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,
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,
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,

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site