Ask coding questions

← Back to all posts
how tofix
klausef (1)

class NewClass{

String Student_id;
String last_name;
String first_name;
String email;

public NewClass
    (String Student_id, String last_name, String first_name, String email) {
    this.Student_id = Student_id;
    this.last_name = last_name;
    this.first_name = first_name;
    this.email = email;
}

}

public static class NewClass {

public static Scanner scanner = new Scanner(System.in);
public static List<STUDENT> toAddStudent = new ArrayList<>();
public static String actions;

public static void main(String[] args) {
    menu();
}

public static void menu(){
    
    //insert the first batch of student
    inserted_student();
    System.out.println("-----STUDENT LIST-----");
    //display after the student inserted
    fetch_student();
    
    System.out.println();
    
    System.out.println("[1] Add Student");
    System.out.println("[2] Remove Student");
    System.out.println("[3] Search Student");
    
    System.out.println();
    System.out.println("Select your Action:");
    actions = scanner.next();
   
    switch (actions) {
        case "1" -> insert_student();
        case "2" -> remove_student();
        case "3" -> search_student();
        default -> {
        }
    }
}

// display the data
public static void fetch_student(){
    int count=0;
    for(STUDENT list:toAddStudent)
    {
        count++;
        System.out.println(count+" |"+list.Student_id +" |"+ list.last_name +" |"+list.first_name +" |"+ list.email);
    }

}
//insert 4 student
public static void inserted_student(){
    
    toAddStudent.add(new STUDENT("02-19-1539","Nini","Nine L Cruz","[email protected]"));
    toAddStudent.add(new STUDENT("02-19-1683","Bab  ","Baby Daw   ","[email protected]"));
    toAddStudent.add(new STUDENT("02-17-0873","Bibi","Bibi W Awa ","[email protected]"));
    toAddStudent.add(new STUDENT("02-19-1698","Ai-ai","Aian Sy","[email protected]"));
    
}
//insert new student
public static void insert_student(){
    
     String id, last_name,first_name,email;
     
     System.out.println("Student Id: ");
     id =scanner.next();
     System.out.println("Lastname: ");
     last_name =scanner.next();
     System.out.println("Firstname: ");
     first_name =scanner.next();
     System.out.println("Email: ");
     email =scanner.next();
     
     toAddStudent.add(new STUDENT(id,last_name,first_name,email));
     
     
}
//remove a student
public static void remove_student(){
     
     System.out.println("implement the code here!!..");
     System.out.println("remove the student info using student ID");
}
//search a student
public static void search_student(){
    System.out.println("implement the code here!!..");
    System.out.println("search the student info using student ID");
}

}

Comments
hotnewtop
SixBeeps (5067)

1.) What's the problem? (provide more details than necessary)
2.) Can you link a Repl?