Untitled

 avatar
unknown
java
3 years ago
1.2 kB
3
Indexable
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("Welcome to Platonus!");
        while (true){
            System.out.println("1) Add new student \n" +
                    "2) Display all students in system \n" +
                    "3) Delete particular student from system \n" +
                    "4) Display rating of students (sorted by GPA) \n" +
                    "5) Exit ");
            System.out.println("Input the number: ");
        }

        int choice = sc.nextInt();
        ArrayList<Student> students = new ArrayList<>();
        switch (choice) {
            case 1:
                String fullName = sc.nextLine();
                double gpa = sc.nextDouble();
                students.add(new Student(fullName, gpa));
                break;
            case 2:
                for (int i = 0; i < students.size(); i++) {
                    System.out.println(students.get(i).toString());
                }
                break;
            default:
                System.out.println("Something wrong");
                break;
        }
    }
}
Editor is loading...