Lab Instructions

User Manual:

Open the PDF directly: View PDF PDF.
Page Count: 2

DownloadLab Instructions
Open PDF In BrowserView PDF
Java Programming

COMP-228

LAB ASSIGNMENT #1
Due Date:
Purpose:

Week 03
Marks/Weightage: 10/5%
The purpose of this Lab Assignment is to:
 Practice the use of instance data members, constructors, methods in Java classes and
objects

Read the course’s text book “Java How to program, 11th edition Early Objects”, Chapter 03 and
the lecture notes/ppts. This material provides the necessary information that you need to
complete the exercises.
Instructions: Be sure to read the following general instructions carefully:
References:

This lab should be completed individually by all the students. You will have to demonstrate your
solution in a scheduled lab session and submitting the project through drop box link on e-Centennial.
You must name your Eclipse work space according to the following rule:
FirstName-LastName_SectionNumber_COMP228_Labnumber
For Example: Joh-Smith_Sec001_COMP228_Lab01
Each exercise should be placed in a separate package named firstname-last-name_exercise1,
firstname-last-name_exercise2 etc.
Submit your assignment in a zip file that is named according to the following rule:
FirstName-LastName_SectionNumber_COMP228_Labnumber.zip
Example: Joh-Smith_Sec001_COMP228_Lab01.zip (if your section is 001..)
Apply the naming conventions for variables, methods, classes, and packages:
- variable names start with a lowercase character for the first word and uppercase for every other word
- classes start with an uppercase character of every word
- packages use only lowercase characters
- methods start with a lowercase character for the first word and uppercase for every other word
Exercise #1:

[10 marks]

Write a Java application using eclipse as IDE, that implements the following class(es) as per business requirements
mentioned below:
Create a BasePlusCommissionEmployee class (BasePlusCommissionEmployee.java) that has the following instance
variables:
- Employee ID, first name, last name, base salary, gross sales ( amount in dollars) and commission rate.
Define their data types appropriately.
- Define only getters for employee ID, first name, last name and base salary. Ensure the proper ( no negative
and null values ) data values by implementing data validations.
- Use default value of 200.00 dollars for base salary for all the employees.
Lab Assignment #1

_____________Page 1 of 2

Java Programming

-

-

COMP-228

Define getter and setter for gross sales and commission rate. Ensure their values should never be negative
or zero.
Commission rate should be between 0.1 and 1.0%. Set default value 0.1.
Class should have defined two overloaded constructors:
o One for initializing all the instance data members
o Second for initializing employee ID, first name, base salary only.
Define a public method - double earnings() which calculates employee’s commission ( commission rate *
gross sales + base salary )
Define a public method – String toString() which is used to display the object’s data

Create a driver class – BasePlusCommissionEmployeeTest (BasePlusCommissionEmployeeTest.java) which tests above
class by at least creating two objects of the BasePlusCommissionEmployee class.

Exercise #2:

[10 marks]

Write a Java application that implements the following class(es) as per business requirements mentioned below:
Create a CheckingAccount class (CheckingAccount.java) that has the following instance variables:
- Account number , customer name, account balance
- Define only getter for account number and customer name
- Define getter and setter for account balance. Balance should be positive and there should be minimum
balance of 50.00 dollars all the time.
- Class should have defined a constructor:
o For initializing all the instance data members
- Define one public method – public double withdraw (double amount) which is used for taking out money.
With every withdrawal, there is transaction fee of 2.00 dollars.
- Define a public method – String toString() which is used to display the object’s data
Create a driver class – CheckingAccountTest (CheckingAccountTest.java) which tests above class by at least creating two
objects of the CheckingAccount class with different set of data values.

Evaluation:
Functionality
Correct implementation of classes
(instance variable declarations,
constructors, getter and setter
methods etc.)
Correct implementation of driver
classes (declaring and creating objects,
calling their methods, interacting with
user, displaying results)
Comments, correct naming of
variables, methods, classes, etc.
Friendly input/output
Total
Lab Assignment #1

70%

20%

5%
5%
100%
_____________Page 2 of 2



Source Exif Data:
File Type                       : PDF
File Type Extension             : pdf
MIME Type                       : application/pdf
PDF Version                     : 1.4
Linearized                      : No
Page Count                      : 2
Language                        : en-CA
Tagged PDF                      : Yes
XMP Toolkit                     : 3.1-701
Producer                        : Microsoft® Word 2013
Title                           : Lab
Creator                         : ilia
Creator Tool                    : Microsoft® Word 2013
Create Date                     : 2018:09:14 10:24:24-04:00
Modify Date                     : 2018:09:14 10:24:24-04:00
Document ID                     : uuid:EF76DE9E-B665-43D9-AAA8-2BB39474C7E4
Instance ID                     : uuid:EF76DE9E-B665-43D9-AAA8-2BB39474C7E4
Part                            : 1
Conformance                     : A
Author                          : ilia
EXIF Metadata provided by EXIF.tools

Navigation menu