Lab Exp 5 FD-Classes-1
Lab Exp 5 FD-Classes-1
CCS0023L
(Object Oriented Programming)
EXERCISE
5
Creating Classes and Objects
Cognitive
a) understand how object-oriented programming and some of its concepts
b) understand the classes and objects
c) understand how instance variables/methods and class(static) variables/methods are being
used
Psychomotor:
a) construct a program using classes and objects
b) compile and debug the error of the program
Affective
a) appreciate the concept behind this experiment
In a way, a class and its objects have the relationship of a data type and variables. A class is
simply a template for holding objects. It is abstract but objects are real.
Classes are generally declared using the keyword “class”.
III. EXPERIMENTAL PROCEDURE: Create the Class Diagram of the following program
description using JDeveloper/NetBeans.
A. Make a class named Students which will contain the following fields:
Student Name (String), Student ID (Integer), and Midterm Grade (Double) with the
following default values: John Smith, 12345678, 70.00 respectively (3)
1. Create a constructor that will accept values for all 3 fields respectively and
assign the values to the class variables
2. Create the standard methods for the Students class (Setters and Getters)
3. Create a custom method for the Students class called display_information which
simply displays the following:
Welcome (Name of student)!
Your Student ID is: (Student ID)
Your current Midterm GPA for this class is: (Midterm Grade)
The computation for the GPA is 40% of midterm grade + 60% of the final grade
Requirements:
1. Submit your codes in a single file (txt or java is accepted). Do not zip the files
if you have more than 1 file to upload.
2. Screenshot at least 3 sample outputs and paste it in this document.
3. Copy and paste your source codes at the end of this document after the output
screenshots. Do not forget to label everything.
3. Create a class that graphs the grade distribution (number of A’s, B’s, C’s, D’s, and
F’s) horizontally by printing lines with proportionate numbers of asterisks
corresponding to the percentage of grades in each category. Write methods to set the
number of each letter grade; red the number of each letter grade, return the total
number of grades, return the percent of each letter grade as a whole number between 0
and 100, inclusive; and draw the graph. Set it up so that 50 asterisks correspond to
100% (each one corresponds 2%), include a scale on the horizontal axis indicating
each 10% increment from 0 to 100%, and label each line with its letter grade. For
example, if there are 1 A’s, 4 B’s, 6 C’s, 2 D’s and 1 F, the total number of grades is
14, the percentage of A’s is 7, percentage of B’s is 29, percentage of C’s is 43,
percentage of D’s is 14, and percentage of F’s is 7. The A row would contain 4
asterisks (7% of 50 rounded to the nearest the B row 14, the C row 21, the D row 7,
and the F row 4, so the graph would look like this
0 10 20 30 40 50 60 70 80 90 100
***************************************************
**** A
************** B
********************* C
******* D
**** F
A class is a blueprint from which you can create the instance, i.e., objects. While An object is the
instance of the class, which helps programmers to use variables and methods from inside the class.