Programming Assignment Unit 3
Programming Assignment Unit 3
CS 1102-01 - AY2024-T5
2. Programming Assignment Unit 3
Requirements:
Use individual variables to store student information such as name, ID, age, and
grade.
Student Management:
Administrator Interface:
Display a menu with options to add a new student, update student information,
and view student details.
Prompt the administrator for necessary inputs and perform the requested
operations using the StudentManagement logic.
Error Handling:
Implement error handling to manage cases where the student ID is not found or
invalid inputs are provided.
Documentation:
Provide comprehensive documentation.
Include instructions for running the program and interacting with the
administrator interface.
Remember to use appropriate variable names and follow coding best practices.
THE PROGRAM :
import java.util.Scanner;
class Student {
private String name;
private String id;
private int age;
private int grade;
class StudentManagement {
private static int totalStudents = 0;
private static Student[] students = new Student[100];
public static void addStudent(String name, String id, int age, int grade) {
students[totalStudents] = new Student(name, id, age, grade);
totalStudents++;
}
while (true) {
System.out.println("Student Record Management System");
System.out.println("1. Add new student");
System.out.println("2. Update student information");
System.out.println("3. View student details");
System.out.println("4. Quit");
System.out.print("Enter your choice: ");
int choice = scanner.nextInt();
scanner.nextLine(); // Consume newline character
switch (choice) {
case 1:
System.out.print("Enter name: ");
String name = scanner.nextLine();
System.out.print("Enter ID: ");
String id = scanner.nextLine();
System.out.print("Enter age: ");
int age = scanner.nextInt();
System.out.print("Enter grade: ");
int grade = scanner.nextInt();
scanner.nextLine(); // Consume newline character
StudentManagement.addStudent(name, id, age, grade);
break;
case 2:
System.out.print("Enter ID of student to update: ");
String updateId = scanner.nextLine();
System.out.print("Enter new age: ");
int updateAge = scanner.nextInt();
System.out.print("Enter new grade: ");
int updateGrade = scanner.nextInt();
scanner.nextLine(); // Consume newline character
StudentManagement.updateStudentInformation(updateId, updateAge, updateGrade);
break;
case 3:
StudentManagement.viewStudentDetails();
break;
case 4:
System.out.println("Exiting program...");
System.exit(0);
break;
default:
System.out.println("Invalid choice! Please try again.");
break;
}
System.out.println();
}
}
}
What the program looks like when I write it and try to run it :
The appearance of the program after overcoming the errors and the success of the code in
documenting the student records management system.
Student Record Management System Documentation
The Student Record Management System is a Java program that allows administrators to manage
student records efficiently. It provides functionalities to add new students, update student
information, and view student details.
Table of Contents
1. Installation and Setup
2. Running the Program
3. Interacting with the Administrator Interface
4. Error Handling
The Student Record Management System will start running and display the Administrator
Interface menu.
Interacting with the Administrator Interface
The Administrator Interface allows you to perform various operations on student records. Follow
the instructions below to interact with the interface:
1. When prompted with the menu, enter the number corresponding to the desired operation
and press Enter:
o Enter 1 to add a new student.
o Enter 2 to update student information.
o Enter 3 to view student details.
o Enter 4 to quit the program.
2. If you choose to add a new student (1), follow the prompts to enter the student's name,
ID, age, and grade. Press Enter after each input.
3. If you choose to update student information (2), enter the ID of the student you want to
update. Then, follow the prompts to enter the new age and grade for the student. Press
Enter after each input.
4. If you choose to view student details (3), the system will display the name, ID, age, and
grade of each student in the record.
5. To quit the program (4), the program will terminate, and you will exit the Administrator
Interface.
Error Handling
The Student Record Management System includes error handling to manage certain cases. Here
are the possible error scenarios and how they are handled:
1. Invalid Choice: If an invalid choice is entered in the Administrator Interface menu, an
error message is displayed, and the menu is shown again to re-enter a valid choice.
2. Student ID Not Found: If a non-existent student ID is entered when updating student
information, an error message is displayed, and the update operation is not performed.
The Administrator Interface menu is shown again for further operations.
- Java Documentation
Java Tutorials by Oracle: These tutorials were used to gain a better understanding of Java
programming concepts and best practices. Available at:
- Java Tutorials
Stack Overflow: This online community helped in troubleshooting and finding solutions
to specific programming queries. Available at:
- Stack Overflow
GeeksforGeeks: This website provided additional resources and examples for Java
programming concepts. Available at:
- GeeksforGeeks Java