Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
16 views

Programming Assignment Unit 3

Uploaded by

Tornado Fair
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

Programming Assignment Unit 3

Uploaded by

Tornado Fair
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 12

1.

CS 1102-01 - AY2024-T5
2. Programming Assignment Unit 3

Programming Assignment Unit 3


Completion requirements
To do: Make a submission
Opened: Thursday, 4 July 2024, 12:05 AM
Due: Thursday, 11 July 2024, 11:55 PM
Create a robust Student Record Management System in Java to empower
administrators with efficient tools for handling student records. This system
should encompass functionalities such as adding new students, updating
student information, and viewing student details.

Requirements:

Student Data Storage:

Use individual variables to store student information such as name, ID, age, and
grade.

Student Management:

Develop a set of logically separated methods/functions within a dedicated


classless structure, employing static variables for storing the total number of
students and the student list.

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.

Submit the assignment in MS Word or PDF file.

This assignment will be assessed by your instructor using the rubric


below.

 THE PROGRAM :
import java.util.Scanner;

class Student {
private String name;
private String id;
private int age;
private int grade;

public Student(String name, String id, int age, int grade) {


this.name = name;
this.id = id;
this.age = age;
this.grade = grade;
}

public String getName() {


return name;
}

public String getId() {


return id;
}

public int getAge() {


return age;
}

public int getGrade() {


return grade;
}

public void setAge(int age) {


this.age = age;
}

public void setGrade(int grade) {


this.grade = 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++;
}

public static void updateStudentInformation(String id, int age, int grade) {


boolean found = false;
for (int i = 0; i < totalStudents; i++) {
if (students[i].getId().equals(id)) {
students[i].setAge(age);
students[i].setGrade(grade);
found = true;
break;
}
}
if (!found) {
System.out.println("Student ID not found!");
}
}

public static void viewStudentDetails() {


for (int i = 0; i < totalStudents; i++) {
System.out.println("Name: " + students[i].getName());
System.out.println("ID: " + students[i].getId());
System.out.println("Age: " + students[i].getAge());
System.out.println("Grade: " + students[i].getGrade());
System.out.println("-----------");
}
}
}

public class Main {


public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);

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

Installation and Setup


To use the Student Record Management System, follow these steps:
1. Ensure that you have Java Development Kit (JDK) installed on your machine. If not, you
can download it from the official Oracle website: Java SE Downloads.
2. Download the provided Java source code file (Main.java) to your computer.
3. Open a command-line interface or terminal.

Running the Program


To run the Student Record Management System program, follow these steps:
1. Navigate to the directory where you downloaded the Main.java file using
the cd command.
2. Compile the Java source code file using the java command:
This will generate the bytecode file (Main.class) that can be executed.

Run the program using the java command:

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.

references and sources:


 Oracle Java Documentation: This documentation was used as a reference for Java syntax,
classes, and methods. Available at:

- 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

You might also like