Lab Assessment 1 August 2024RUBICKS
Lab Assessment 1 August 2024RUBICKS
Programme BCSI/BITI
Harprith Kaur
Student’s Declaration:
I declare that:
I understand what is meant by plagiarism
This assignment is all my own work and I have acknowledged any use of the
published or unpublished works of other people.
I hold a copy of this assignment which I can produce if the original is lost or
damaged
CLO2 Display the ability to build an object-oriented computer application using JAVA
programming language. (P4, PLO3)
Description of Coursework #1:
Part 1
Create a class named Student to represent a student's profile in a school system. The class should
meet the following specifications:
1. Attributes:
name (String): the student's full name.
id (int): the student's ID number.
gpa (double): the student's grade point average (GPA).
credits (int): the number of credits the student has earned.
2. Constructor:
A parameterized constructor that initializes all the attributes (name, id, gpa,
credits).
3. Getters and Setters:
Provide getter and setter methods for the attributes, but ensure that:
The gpa cannot be negative or greater than 4.0.
The credits cannot be negative.
4. Additional Methods:
addCredits(int credits): A method to add credits to the student's profile. Ensure the
credits are positive before adding them.
isEligibleForGraduation(): A method that returns true if the student has at least
120 credits and a gpa of 2.0 or higher, otherwise returns false.
5. toString() Method:
Override the toString() method to display the student’s details in the following
format:
Student Name: <name>, ID: <id>, GPA: <gpa>, Credits: <credits>
Part 2
Main Method:
In the main method, create at least two Student objects with different values.
Display the details of each student using the toString() method.
Add credits to one of the students and check if they are eligible for graduation.
Sample Output