forked from SadeeshaJayaweera/Java-Practical-Codes-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSavingsAccount.java
More file actions
35 lines (27 loc) · 956 Bytes
/
Copy pathSavingsAccount.java
File metadata and controls
35 lines (27 loc) · 956 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*
This is the Question Number 8 in the assignment regarding static variables
the term static refers The static variable gets memory only once in the class area at the time of class loading.
the test code is named as TestClass_SavingsAccount ( Object Code)
*/
public class SavingsAccount {
private double SavingBalance;
private static double annualInterestRate;
public SavingsAccount(double SavingBalance, double annualInterestRate)
{
this.SavingBalance=SavingBalance;
this.annualInterestRate=annualInterestRate;
}
public void calculateMonthlyInterest()
{
double MonthlyInterest= (SavingBalance * annualInterestRate)/12;
SavingBalance=SavingBalance+MonthlyInterest;
}
public static void modifyInterestRate(double newAnnualInterestRate)
{
annualInterestRate=newAnnualInterestRate;
}
public double getSavingBalance()
{
return SavingBalance;
}
}