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

Problem 1 DSA Documentation

Uploaded by

ijttalabucon
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)
20 views6 pages

Problem 1 DSA Documentation

Uploaded by

ijttalabucon
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

COLLEGE OF ENGINEERING DEPARTMENT

Information Technology

Module 0 – MCO2
Introduction to JAVA in Preparation
to DATA STRUCTURE AND ALGORITHM

Submitted By:

Aldrin Rey N. Taberara


Mark Lawrence P. Lacdao
Euri Christian F. Ripalda

Submitted To:
Salvador L. Flores Jr.
Assistant Professor II
I. Description and Program

 This Java program demonstrates a simple student management system with basic
object-oriented programming principles.

 The program consists of two classes: StudentManagement (main class) and Student (a
custom class representing student information)

Problem:
Create a Java program that simulates a student management system. The program should
allow the user to create a student object, display the student's initial details, update the
student's details, and then display the updated information.
Algorithm:
Start
Create a Student Object:
Declare a new object of the Student class.
Initialize the object's attributes:
name
rollNumber
grades (a list of integers)

Print Initial Details:


Call the printDetails() method of the Student object.
This method displays the current values of name, rollNumber, and grades.

Update Student Details:


Call the setDetails() method of the Student object.
Pass the new values for name, rollNumber, and grades as arguments.
This method updates the object's attributes with the new values.

Print Updated Details:


Call the printDetails() method of the Student object again. This time, it will display the
updated values of the attributes.
End

Pseudocode:
START
Create a new Student object
Initialize student's name, roll number, and grades
Print student's details
Update student's name, roll number, and grades
Print student's updated details
END
Flow Chart:
Program Code:

import java.util.ArrayList;
import java.util.List;

public class StudentManagement {


public static void main(String[] args) {
Student student = new Student("Alice", 123, new ArrayList<>(List.of(85, 92,
78)));

student.printDetails();

student.setDetails("Bob", 456, new ArrayList<>(List.of(90, 88, 95)));

student.printDetails();
}
}

class Student {
private String name;
private int rollNumber;
private List<Integer> grades;

public Student(String name, int rollNumber, List<Integer> grades) {


this.name = name;
this.rollNumber = rollNumber;
this.grades = grades;
}

public void printDetails() {


System.out.println("Name: " + name);
System.out.println("Roll Number: " + rollNumber);
System.out.println("Grades: " + grades);
}

public void setDetails(String name, int rollNumber, List<Integer> grades) {


this.name = name;
this.rollNumber = rollNumber;
this.grades = grades;
}
}
II. Program Execution
1. The `Student` class defines a student with three key attributes:
a. `name`: A string representing the student's name
b. `rollNumber`: An integer representing a unique student identifier
c. `grades`: A list of integers representing the student's grades
2. The `Student` class provides two key methods:
a. `printDetails()`: Displays the current student's information (name, roll number, and
grades)
b. `setDetails()`: Allows updating all of the student's information at once
3. In the `main()` method of `StudentManagement`, the program demonstrates the usage
of the `Student` class:
a. First, it creates a `Student` object named `student` with initial details for Alice
- Name: Alice
- Roll Number: 123
- Grades: [85, 92, 78]
b. Prints Alice's initial details
c. Then updates the student's details to Bob's information
- Name: Bob
- Roll Number: 456
- Grades: [90, 88, 95]
d. Prints Bob's updated details

When executed, the program will output:


III. Documentation

Online
Meetings
A group

conversation was promptly established to facilitate task delegation, discussions,


and inquiries.

You might also like