0% found this document useful (0 votes)
6 views6 pages

Programming Assignment Unit 3

The document presents a Java program for a Student Record Management System, allowing users to add, update, and view student details. It includes a main class with methods for managing student records and utilizes an ArrayList to store student information. The program is part of a programming assignment for a course taught by Salah Jabareen in July 2025.

Uploaded by

nazilaramzi25
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)
6 views6 pages

Programming Assignment Unit 3

The document presents a Java program for a Student Record Management System, allowing users to add, update, and view student details. It includes a main class with methods for managing student records and utilizes an ArrayList to store student information. The program is part of a programming assignment for a course taught by Salah Jabareen in July 2025.

Uploaded by

nazilaramzi25
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/ 6

Java Solutions for Student Record Management

CS 1102-01 Programming 1 - AY2025-T5

Programming Assignment Unit 3

Instructor: Salah Jabareen

July 10, 2025


The code:
package PAU3;

import java.util.ArrayList;
import java.util.Scanner;

public class StudentManagement {

static ArrayList<Student> students = new ArrayList<>();


static Scanner scanner = new Scanner(System.in);

static class Student {


String name;
int id;
int age;
double grade;

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


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

@Override
public String toString() {
return "Student ID: " + id + ", Name: " + name + ", Age: " +
age + ", Grade: " + grade;
}
}

public static void main(String[] args) {


while (true) {
System.out.println("\n*** 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. Exit");
System.out.print("Enter your choice: ");
int choice = scanner.nextInt();
switch (choice) {
case 1:
addStudent();
break;
case 2:
updateStudent();
break;
case 3:
viewStudent();
break;
case 4:
System.out.println("Exiting...");
System.exit(0);
break;
default:
System.out.println("Invalid choice. Please enter a
valid option.");
}
}
}

static void addStudent() {


System.out.print("Enter Student ID: ");
int id = scanner.nextInt();
scanner.nextLine();
System.out.print("Enter Name: ");
String name = scanner.nextLine();
System.out.print("Enter Age: ");
int age = scanner.nextInt();
System.out.print("Enter Grade: ");
double grade = scanner.nextDouble();

students.add(new Student(id, name, age, grade));


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

static void updateStudent() {


System.out.print("Enter Student ID to update: ");
int id = scanner.nextInt();
for (Student student : students) {
if (student.id == id) {
scanner.nextLine();
System.out.print("Enter new Name: ");
student.name = scanner.nextLine();
System.out.print("Enter new Age: ");
student.age = scanner.nextInt();
System.out.print("Enter new Grade: ");
student.grade = scanner.nextDouble();
System.out.println("Student updated successfully!");
return;
}
}
System.out.println("Student ID not found.");
}

static void viewStudent() {


System.out.print("Enter Student ID to view: ");
int id = scanner.nextInt();
for (Student student : students) {
if (student.id == id) {
System.out.println(student);
return;
}
}
System.out.println("Student ID not found.");
}
}

Documentation:

The outputs:

- Add New Student:


- Update Information:

- View Student Details:


Reference

Eck, D. J. (2022). Introduction to programming using java version 9, JavaFX edition. Licensed

under CC 4.0. https://math.hws.edu/javanotes/

You might also like