-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSavingAccount.java
More file actions
55 lines (31 loc) · 1 KB
/
Copy pathSavingAccount.java
File metadata and controls
55 lines (31 loc) · 1 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
class SavingAccount {
public static double annualInterestRate = 0.03;
public double savingBalance;
public void calculateMonthlyInterest(double savingBalance){
savingBalance = savingBalance + (savingBalance*annualInterestRate)/12;
}
public void printBalance(){
calculateMonthlyInterest();
System.out.printf("Saving is %.2f",savingBalance);
}
public static void modifyInterestRate(double annualInterestRate){
System.out.println("New annual interestrate has been modified");
}
}
class TestSavingAccount{
public static void main(String args[])
{
SavingAccount saver1 = new SavingAccount();
SavingAccount saver2 = new SavingAccount();
saver1.calculateMonthlyInterest(1.22);
saver2.calculateMonthlyInterest(100.99);
saver1.printBalance();
saver2.printBalance();
saver1.modifyInterestRate(0.04);
saver1.calculateMonthlyInterest(1.22);
saver1.printBalance();
saver2.calculateMonthlyInterest(100.99);
saver2.modifyInterestRate(0.04);
saver1.printBalance();
}
}