Skip to content

Practice Problem 11

Seanti edited this page Mar 26, 2025 · 1 revision

Problem:

Create a program that:

  1. Stores student names as keys and grades as values in a HashMap.

  2. Allows the user to add students with grades.

  3. Allows the user to retrieve a student's grade by entering their name.

  4. Allows the user to remove a student from the list.

  5. Uses a loop to keep asking for actions until the user chooses to exit.


Sample Output:

1 - Add Student and Grade  
2 - Get Student Grade  
3 - Remove Student  
4 - Display All Students  
5 - Exit  
Enter your choice: 1  
Enter student name: Pedro Reyes  
Enter grade: 88  
Student added!  

1 - Add Student and Grade  
2 - Get Student Grade  
3 - Remove Student  
4 - Display All Students  
5 - Exit  
Enter your choice: 1  
Enter student name: Anna Cruz  
Enter grade: 95  
Student added!  

1 - Add Student and Grade  
2 - Get Student Grade  
3 - Remove Student  
4 - Display All Students  
5 - Exit  
Enter your choice: 2  
Enter student name: Anna Cruz  
Anna Cruz's grade: 95  

1 - Add Student and Grade  
2 - Get Student Grade  
3 - Remove Student  
4 - Display All Students  
5 - Exit  
Enter your choice: 3  
Enter student name: Pedro Reyes  
Student removed!  

1 - Add Student and Grade  
2 - Get Student Grade  
3 - Remove Student  
4 - Display All Students  
5 - Exit  
Enter your choice: 5  
Exiting program.

Clone this wiki locally