import java.util.Scanner; import java.util.ArrayList; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); ArrayList list = new ArrayList<>(); int choice; do { System.out.println("\nChoose one of the options:"); System.out.println("1- Enter the information of a faculty"); System.out.println("2- Enter the information of a student"); System.out.println("3- Print tuition invoice for a student"); System.out.println("4- Print faculty information"); System.out.println("5- Enter the information of a staff member"); System.out.println("6- Print the information of a staff member"); System.out.println("7- Delete a person"); System.out.println("8- Exit Program\n"); System.out.print("Enter your choice: "); choice = scanner.nextInt(); switch (choice) { case 1: enterFacultyInfo(scanner, list); break; case 2: enterStudentInfo(scanner, list); break; case 3: printStudentInfo(scanner, list); break; case 4: printFacultyInfo(scanner, list); break; case 5: // Enter staff information break; case 6: // Print staff information break; case 7: // Delete a person break; case 8: System.out.println("Exiting Program."); break; default: System.out.println("Invalid choice. Please try again."); } } while (choice != 8); } private static void enterFacultyInfo(Scanner scanner, ArrayList list) { System.out.println("Enter the faculty info:"); System.out.print("Name: "); String name = scanner.next(); String id; do { System.out.print("id: "); id = scanner.next(); if (idFormat(id) && !duplicateCheck(id, list)) { break; } else { System.out.println("Invalid ID format or duplicate id."); } } while (true); String rank; do { System.out.print("Rank: "); rank = scanner.next().toUpperCase(); if (rank.equals("PROFESSOR") || rank.equals("ADJUNCT")) { break; } else { System.out.println(rank + " is an invalid rank."); } } while (true); String department; do { System.out.print("Department: "); department = scanner.next().toUpperCase(); if (department.equals("MATHEMATICS") || department.equals("ENGLISH") || department.equals("ENGINEERING")) { break; } else { System.out.println(department + " is an invalid department."); } } while (true); Faculty faculty = new Faculty(name, id, department, rank); list.add(faculty); } private static void enterStudentInfo(Scanner scanner, ArrayList list) { System.out.println("Enter the student info:"); System.out.print("Name: "); String studentName = scanner.next(); String studentId; do { System.out.print("Id: "); studentId = scanner.next(); if (idFormat(studentId) && !duplicateCheck(studentId, list)) { break; } else { System.out.println("Invalid ID format or duplicate id."); } } while (true); double gpa; do { System.out.print("Gpa: "); gpa = scanner.nextDouble(); if (gpa >= 0 && gpa <= 4.5) { break; } else { System.out.println("Please enter a GPA between 0 and 4.5."); } } while (true); int credits; do { System.out.print("Credit Hours: "); credits = scanner.nextInt(); if (credits >= 0 && credits <= 100) { break; } else { System.out.println("Please enter a reasonable number of credits."); } } while (true); Student student = new Student(studentName, studentId, gpa, credits); list.add(student); } private static void printStudentInfo(Scanner scanner, ArrayList list) { System.out.println("Enter the Student's id:"); String studentId = scanner.next(); boolean found = false; for (Person person : list) { if (person instanceof Student && person.getId().equals(studentId)) { found = true; person.print(); break; } } if (!found) { System.out.println(studentId + " not found."); } } private static void printFacultyInfo(Scanner scanner, ArrayList list) { System.out.println("Enter the Faculty’s id:"); String facultyId = scanner.next(); boolean found = false; for (Person person : list) { if (person instanceof Faculty && person.getId().equals(facultyId)) { found = true; person.print(); break; } } if (!found) { System.out.println(facultyId + " not found."); } } private static boolean idFormat(String id) { // Implement ID format validation return true; // Placeholder } private static boolean duplicateCheck(String id, ArrayList list) { // Implement duplicate ID check return false; // Placeholder } } class Person { private String name; private String id; public Person(String name, String id) { this.name = name; this.id = id; } public String getId() { return id; } public void print() { System.out.println("Name: " + name); System.out.println("ID: " + id); } } class Faculty extends Person { private String department; private String rank; public Faculty(String name, String id, String department, String rank) { super(name, id); this.department = department; this.rank = rank; } @Override public void print() { super.print(); System.out.println("Department: " + department); System.out.println("Rank: " + rank); } } class Student extends Person { private double gpa; private int credits; public Student(String name, String id, double gpa, int credits) { super(name, id); this.gpa = gpa; this.credits = credits; } @Override public void print() { super.print(); System.out.println("GPA: " + gpa); System.out.println("Credits: " + credits); } }