hey i need to make a program where a menu pops up. the user will enter a number and the program will continue doing whatever they have selected. so if they hit 1 they can add a student to the arraylist. 2 is suppose to delete a student after the user enters and id number. 3 shows size fo arraylist. 4 prints out the name and id of each student on arraylist. 5 finds a student with id. i need help on 2, 4 , and 5. please can someone tell me how to print the name and id of a student while pulling it from arraylist.
import java.util.*; public class NollisP3A{ public static void main (String[] args){ ///student kid = new student(id, name); ArrayList studentList = new ArrayList(); String menu= "Enter 1 to: Add a student to the list.\nEnter 2 to: Delete a student from the list.\nEnter 3 to: Display number of students in the list.\nEnter 4 to: Display information (ID and name) for all students.\nEnter 5 to. Find a student with a specific ID.\nEnter 0 to: Quit the program."; System.out.println(menu); Scanner input1 = new Scanner(System.in); int choice = input1.nextInt(); int n = 0; if (choice == 0){ System.out.println("Program Ended"); System.exit(0); }//end if else{ while(choice!= 0){ switch (choice){ case 1: System.out.println("Enter student ID"); Scanner idInput = new Scanner(System.in); int id = idInput.nextInt(); System.out.println("Enter student name"); Scanner nameInput = new Scanner(System.in); String name = nameInput.next(); student kid = new student(id,name); studentList.add(n++, kid); System.out.print(kid.id +"\n\n"); System.out.println(menu); choice = input1.nextInt(); break; case 2: System.out.println("Enter ID number to delete the student"); Scanner delete = new Scanner(System.in); // kid.id = delete.nextInt(); // studentList.remove(kid.id); System.out.println(menu); choice = input1.nextInt(); break; case 3: System.out.println("Number of Students: " + studentList.size()); System.out.println(menu); choice = input1.nextInt(); break; case 4: //display students and id int i =0; while(i < studentList.size()){ //System.out.println(((student)studentList.get(i).getName())); i++; } System.out.println(menu); choice = input1.nextInt(); break; case 5: System.out.println("Enter the ID number."); Scanner findId = new Scanner(System.in); //System.out.println(kid.id); System.out.println(menu); choice = input1.nextInt(); break; default: System.out.println("Error: Try again."); System.out.println(menu); choice = input1.nextInt(); }//end switch }//end while }//end else getName(){ } }//end main }//end of nollis class student{ int id; String name; student(){ } student(int newId, String newName){ id=0; name= null; getId(); getName(); id = newId; name= newName; } int getId(){ return this.id; } String getName(){ return this.name; } }