-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathInterest.java
34 lines (29 loc) · 1.13 KB
/
Interest.java
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
package nadine;
/**
* This class implements a simple program that
* will compute the amount of interest that is
* earned on $17,000 invested at an interest
* rate of 0.027 for one year. The interest and
* the value of the investment after one year are
* printed to standard output.
*/
public class Interest {
public static void main(String[] args) {
/* Declare the variables. */
double principal; // the value of the investment.
double rate; // the annual interest rate.
double interest; // interest earned in one year.
/* Do the computations. */
principal = 17000;
rate = 0.027;
interest = principal * rate; // compute the interest.
principal = principal + interest;
// Compute value of interest after one year, with interest.
//(Note: The new value replaces the old value of principal.)
/* Output the results. */
System.out.print("The interest earned in $");
System.out.println(interest);
System.out.print("The value of the investment after one year is $");
System.out.println(principal);
} // end of main()
} // end of class Interest