Problem Statement
Definition
- Class:
- DepositProfit
- Method:
- depositTerm
- Parameters:
- int, int, int
- Returns:
- int
- Method signature:
- int depositTerm(int amount, int annualInterest, int profit)
- (be sure your method is public)
Notes
- The monthly interest is calculated as (current deposit amount) * (annual interest rate in percent) / (100*12).
Constraints
- amount will be between 10 and 10000, inclusive.
- annualInterest will be between 4 and 24, inclusive.
- profit will be between 1 and amount, inclusive.
Examples
1000
12
20
Returns: 2
The monthly interest rate is 1%. At the end of the first month, the interest added is 1000*0.01 = 10, for a new total balance of 1010. At the end of the second month, the interest added is 1010*0.01 = 10.10, for a total balance of 1020.10. At this point, the profit is 20.10, which is greater than 20.
10
4
10
Returns: 236
5000
24
4000
Returns: 30
1000
6
5
Returns: 1
The monthly interest rate is 0.5%. At the end of the first month, the interest added is equal to the profit wanted.
3411
14
1536
Returns: 33
5509
13
3857
Returns: 50
5409
7
1891
Returns: 52
4785
12
706
Returns: 14
4059
19
2828
Returns: 34
3592
8
3483
Returns: 103
9302
12
8476
Returns: 66
8275
24
2650
Returns: 15
610
23
383
Returns: 26
6181
19
3806
Returns: 31
6452
23
4451
Returns: 28
583
16
30
Returns: 4
1935
20
1009
Returns: 26
1201
12
357
Returns: 27
282
10
15
Returns: 7
1109
10
799
Returns: 66
2421
19
1574
Returns: 32
6721
4
4060
Returns: 143
8184
21
1870
Returns: 12
2564
17
1281
Returns: 29
6882
23
5290
Returns: 31
8006
14
6183
Returns: 50
672
16
652
Returns: 52
1217
23
376
Returns: 15
889
18
731
Returns: 41
1015
24
14
Returns: 1
1950
8
887
Returns: 57
4273
19
2950
Returns: 34
1104
7
1090
Returns: 119
7569
23
7086
Returns: 35
5753
21
960
Returns: 9
5176
14
3659
Returns: 47
9612
6
3914
Returns: 69
2252
6
845
Returns: 64
330
23
78
Returns: 12
1562
12
585
Returns: 32
6651
13
2899
Returns: 34
9680
6
7420
Returns: 115
716
21
445
Returns: 28
4514
18
2198
Returns: 27
5923
16
1916
Returns: 22
4327
9
4220
Returns: 92
7429
10
1304
Returns: 20
2144
24
2105
Returns: 35
9017
13
4937
Returns: 41
4324
7
2694
Returns: 84
3845
15
281
Returns: 6
1256
12
706
Returns: 45
7605
16
705
Returns: 7
5427
21
3322
Returns: 28
6653
15
1861
Returns: 20
5000
18
2369
Returns: 27
3765
8
3419
Returns: 98
1490
17
1366
Returns: 47
3794
4
1038
Returns: 73
745
13
362
Returns: 37
495
16
495
Returns: 53
5936
15
4566
Returns: 46
4722
18
596
Returns: 8
10000
4
10000
Returns: 209
10000
24
404
Returns: 2
400
9
3
Returns: 1
10000
12
201
Returns: 2
36
4
32
Returns: 197
4438
6
4350
Returns: 137
270
4
120
Returns: 111
9459
6
7579
Returns: 118
18
4
8
Returns: 118
8238
12
5176
Returns: 49
10
4
1
Returns: 34
At the end of the first month, the interest added is approximately 3.33 cents. At the end of the 34-th month, the interest added is approximately 3.67 cents. Both these interests are rounded down to 3 cents.
100
12
1
Returns: 1
1000
12
10
Returns: 1
9876
23
9875
Returns: 37