Java Reference
In-Depth Information
30 double interest = balance * rate
/ 100;
31 balance = balance + interest;
32 }
33 }
34
35 /**
36Keeps accumulating interest for a given number of years.
37 @param n the number of years
38 */
39 public void waitYears(int n)
40 {
41 for (int i = 1; i <= n; i++)
42 {
43 double interest = balance * rate
/ 100;
44 balance = balance + interest;
45 }
46 years = years + n;
47 }
48
49 /**
50Gets the current investment balance.
51 @return the current balance
52 */
53 public double getBalance()
54 {
55 return balance;
56 }
57
58 /**
59Gets the number of years this investment has accumulated
60interest.
61 @return the number of years since the start of the
investment
62 */
63 public int getYears()
64 {
65 return years;
66 }
67
68 private double balance;
69 private double rate;
239
240
Search WWH ::




Custom Search