-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathD2-6.txt
30 lines (28 loc) · 1.11 KB
/
D2-6.txt
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
class Account {
public static void main(String[] args) {
double balance = 6000, rateOfInterest = 0.10, interest = 0;
double withdrawal = 500, deposit = 600;
for(int i = 1; i <= 12; ++i) {
balance += deposit;
balance -= deposit;
interest = balance * rateOfInterest;
balance += interest;
System.out.println("The interest for the month " + i + " is " + interest);
}
System.out.println("The balance at the end of the year is " + balance);
}
}
Output:
The interest for the month 1 is 600.0
The interest for the month 2 is 660.0
The interest for the month 3 is 726.0
The interest for the month 4 is 798.6
The interest for the month 5 is 878.46
The interest for the month 6 is 966.3060000000002
The interest for the month 7 is 1062.9366000000002
The interest for the month 8 is 1169.2302600000003
The interest for the month 9 is 1286.1532860000004
The interest for the month 10 is 1414.7686146000005
The interest for the month 11 is 1556.2454760600006
The interest for the month 12 is 1711.8700236660006
The balance at the end of the year is 18830.570260326007