Java Reference
In-Depth Information
44 /**
45Gets the number of years this investment has accumulated
46interest.
47 @return the number of years since the start of the
investment
48 */
49 public int getYears()
50 {
51 return years;
52 }
53
54 private double balance;
55 private double rate;
56 private int years;
57 }
ch06/invest1/InvestmentRunner.java
1 /**
2This program computes how long it takes for an investment
3to double.
4 */
5 public class InvestmentRunner
6 {
7 public static void main(String[] args)
8 {
9 final double INITIAL_BALANCE =
10000;
10 final double RATE = 5;
11 Investment invest = new
Investment(INITIAL_BALANCE, RATE);
12 Invest.waitForBalance(2 *
INITIAL_BALANCE);
13 int years = invest.getYears();
14 System.out.printf(ÐThe investment
doubled afterÑ
15 + years + Ð yearsÑ
16 }
17 }
230
231
Search WWH ::




Custom Search