[go: up one dir, main page]

0% found this document useful (0 votes)
9 views5 pages

Cs 1102 Programming Assignment Unit 3 - Betinol

The document outlines a programming assignment for creating a Student Record Management System in Java. It includes functionalities for adding, updating, and viewing student records, along with the necessary code implementation. The system is designed to assist administrators in efficiently managing student information.

Uploaded by

kbbetinol
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views5 pages

Cs 1102 Programming Assignment Unit 3 - Betinol

The document outlines a programming assignment for creating a Student Record Management System in Java. It includes functionalities for adding, updating, and viewing student records, along with the necessary code implementation. The system is designed to assist administrators in efficiently managing student information.

Uploaded by

kbbetinol
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Programming Assignment Unit 3

CS 1102-1 Programming 1
23 February 2024

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.

Code:

// import scanner function from java util package

import java.util.Scanner;

// Student class which will store the student information

class Student {

String name;

int id;

int age;

int grade;

// initializes the student object

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

this.name = name;

this.id = id;

this.age = age;

this.grade = grade;

}
// studentManagement class to manage student records

class StudentManagement {

static int totalStudents = 0;

static Student[] studentList = new Student[100];

// adds a new student

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

Student newStudent = new Student(name, id, age, grade);

studentList[totalStudents] = newStudent;

totalStudents++;

System.out.println("Student has been added successfully!");

// this updates student information based on ID

public static void updateStudent(int id, int newAge, int newGrade) {

for (int i = 0; i < totalStudents; i++) {

if (studentList[i].id == id) {

studentList[i].age = newAge;

studentList[i].grade = newGrade;

System.out.println("Student information has been updated successfully!");

return;

// error message indicating missing information

System.out.println("Student ID not found!");

// views student details based on ID


public static void viewStudentDetails(int id) {

for (int i = 0; i < totalStudents; i++) {

if (studentList[i].id == id) {

System.out.println("Name is: " + studentList[i].name);

System.out.println("ID number: " + studentList[i].id);

System.out.println("Age is: " + studentList[i].age);

System.out.println("Grade level: " + studentList[i].grade);

return;

// error message indicating missing information

System.out.println("Student ID not found!");

// StudentRecordSystem class for management system

class StudentRecordSystem {

public static void main(String[] args) {

Scanner scanner = new Scanner(System.in);

int choice;

int id, age, grade;

String name;

// serves as the menu for upddating student records

do {

System.out.println("\nStudent 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. Exit");

System.out.print("Enter your choice: ");

choice = scanner.nextInt();

switch (choice) {

case 1:

System.out.print("Enter name: ");

scanner.nextLine();

name = scanner.nextLine();

System.out.print("Enter ID: ");

id = scanner.nextInt();

System.out.print("Enter age: ");

age = scanner.nextInt();

System.out.print("Enter grade: ");

grade = scanner.nextInt();

StudentManagement.addStudent(name, id, age, grade);

break;

case 2:

System.out.print("Enter student ID to update: ");

id = scanner.nextInt();

System.out.print("Enter new age: ");

age = scanner.nextInt();

System.out.print("Enter new grade: ");

grade = scanner.nextInt();

StudentManagement.updateStudent(id, age, grade);

break;

case 3:

System.out.print("Enter student ID to view details: ");

id = scanner.nextInt();
StudentManagement.viewStudentDetails(id);

break;

case 4:

System.out.println("Closing program.");

break;

default:

// when an invalid choice is selected

System.out.println("Please select a valid value");

} while (choice != 4);

scanner.close();

You might also like