0% found this document useful (0 votes)
5 views3 pages

Geometry and Student Modeling Lab

The document outlines the tasks for Programming 2 (PRG620S) Labs for Week 04, which includes creating a student model with attributes and constructors, determining the quadrant of a point in a Cartesian system, and modifying a Java program to print student details. It provides specific requirements for each lab task, including sample runs and expected outputs. Students are required to implement the tasks using an IDE and submit their work for grading.

Uploaded by

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

Geometry and Student Modeling Lab

The document outlines the tasks for Programming 2 (PRG620S) Labs for Week 04, which includes creating a student model with attributes and constructors, determining the quadrant of a point in a Cartesian system, and modifying a Java program to print student details. It provides specific requirements for each lab task, including sample runs and expected outputs. Students are required to implement the tasks using an IDE and submit their work for grading.

Uploaded by

tuhafenijason05
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Programming 2 (PRG620S) Labs, Week 04 (03 to 07 March 2025)

Lab04_A Create a project to model students with firstname, lastname, age, gender
and student number. Create two constructors, one to be used as default and another to
include all attributes. Add a class attribute to keep count of all registered students. Use the
class attribute to generate student numbers with the following format 22201XYZ, where
XYZ is the current count provided by the class attribute. Implement the respective getters
and setters for each attribute. Now, given a list of student information, create the
respective objects and print out their details. See samples below, make sure the student
class has a toString method.

Sample Run1
2
John Doe 29 M
Kelly Daniela 40 F

Output1:
Full names : John Doe
Age : 29
Gender : M
Student Number : 22201001

Full names : Kelly Daniela


Age : 40
Gender : F
Student Number : 22201002

LABO4_B In plane geometry, the x- and y axis of a 2D Cartesian system divides it into
four infinite regions called quadrants. Your task is to model each point with an x-value and
y-value. Apart from the constructors, getters, and setters, implement a getQuadrant
method to determine the region in which a given point falls.

Sample Run1 Sample Run2


Enter the x and y value: 5 8 Enter the x and y value: 7 -3
Output1: Point (5,8) is in Quadrant I Output2: Point (7,-3) is in Quadrant IV

Page 1 of 3
Lab04_C A Java program to create objects and print out attribute values. Modify the
program below using any IDE of your choice and submit the new copy on VPL for
automatic grading.

Package student;
class Student {
//ATTRIBUTE/PROPERTY SECTION
String studName, studDept;
int test1, test2, assign1, studNumber, totalMark;
}
public class Student1 {
public static void main(String[] args) {
//CREATION OF OBJECT
Student obj = new student();
[Link] = "James Smith";
//PRINTING SECTION-METHOD
[Link]("Student Name: "+[Link]);
}
}

Lab work:
(a) change the object name to stud
(b) create the following objects and assign these values to them:

studNumber: 93100191
studDept: Computer Science
test1: 23
test2 — 18
assign1 —20

(c) Only the attribute value for studName is currently printed, print out all the other
attribute values
(d) The formula to calculate Total Mark is: totalMark = test1 + test2 + assign1
(e) Submit the modified program on VPL for automatic grading.

Sample run:
Student Name: James Smith

Page 2 of 3
Student Number: 93100191
Student Department: Computer Science
Test1: 23
Test2: 18
Assignment: 20
Total Mark: 61

Page 3 of 3

You might also like