Java Basics
T ra in in g As s ig nmen ts
Document Code 25e-BM/HR/HDCV/FSOFT
Version 1.1
Effective Date 20/11/2012
Hanoi, 06/2019
Lab Guides Data Structure & Algorithm Issue/Revision: x/y
RECORD OF CHANGES
No Effective Date Change Description Reason Reviewer Approver
1 01/Oct/2018 Create new Draft DieuNT1 VinhNV
2 01/Jun/2019 Fsoft template Update DieuNT1 VinhNV
25e-BM/HR/HDCV/FSOFT v1.1 Internal use 2/4
Lab Guides Data Structure & Algorithm Issue/Revision: x/y
Contents
Day 1. Assignment 1: Basics OOP ..................................................................................................4
Objective:.....................................................................................................................................4
Assignment Specifications: ..........................................................................................................4
Problem Descriptions: ..................................................................................................................4
Guidelines:...................................................................................................................................4
25e-BM/HR/HDCV/FSOFT v1.1 Internal use 3/4
Lab Guides Data Structure & Algorithm Issue/Revision: x/y
CODE: JAVA.M.A101
TYPE: SHORT
LOC: 70
DURATION: 30 MINUTES
Day 1. Assignment 1: Basics OOP
Objective:
» Understand basic concept about OOP
Assignment Specifications:
Create class SavingsAccount, your class must have the following features:
Instance variables:
» annualInterestRate to store the annual interest rate for all account holders.
» savingsBalance indicating the amount the saver currently has ondeposit.
Constructor:
» public SavingsAccount(): A default constructor, it should initialize the attributes to 0, 0)
» public public SavingsAccount(double intRate, double savBal): A constructor with parameters, it
creates the SavingsAccount object by setting the two fields to the passed values.
Instance methods:
» Getter/Setter Methods: are used to get/set the value.
» Provide method calculateMonthlyInterest to calculate the monthly interest by multiplying the
savingsBalance by annualInterestRate divided by 12 this interest should be added to
savingsBalance.
Write a program to test class SavingsAccount. Instantiate two savingsAccount objects, saver1 and saver2,
with balances of $2000.00 and $3000.00, respectively. Set annualInterestRate to 4%, then calculate the
monthly interest and print the new balances for both savers.
Then set the annualInterestRate to 5%, calculate the next month’s interest and print the new balances for both
savers.
Problem Descriptions:
» Write a java console program to resolve this assignment
Guidelines:
» Create a project named Java.M.A101, create package fa.training.entities that contains
SavingsAccount class.
» Create a new package named fa.training.main contains SavingsAccountTest class.
25e-BM/HR/HDCV/FSOFT v1.1 Internal use 4/4