Java Reference
In-Depth Information
**4.22
( Financial application: loan amortization schedule ) The monthly payment for a
given loan pays the principal and the interest. The monthly interest is computed by
multiplying the monthly interest rate and the balance (the remaining principal).
The principal paid for the month is therefore the monthly payment minus the
monthly interest. Write a program that lets the user enter the loan amount, number
of years, and interest rate and displays the amortization schedule for the loan. Here
is a sample run:
VideoNote
Display loan schedule
Loan Amount: 10000
Number of Years: 1
Annual Interest Rate: 7
Monthly Payment: 865.26
Total Payment: 10383.21
Payment# Interest Principal Balance
1 58.33 806.93 9193.07
2 53.62 811.64 8381.43
...
11 10.0 855.26 860.27
12 5.01 860.25 0.01
Note
The balance after the last payment may not be zero. If so, the last payment should be
the normal monthly payment plus the final balance.
Hint : Write a loop to display the table. Since the monthly payment is the same for
each month, it should be computed before the loop. The balance is initially the
loan amount. For each iteration in the loop, compute the interest and principal, and
update the balance. The loop may look like this:
for (i = 1 ; i <= numberOfYears * 12 ; i++) {
interest = monthlyInterestRate * balance;
principal = monthlyPayment - interest;
balance = balance - principal;
System.out.println(i + "\t\t" + interest
+ "\t\t" + principal + "\t\t" + balance);
}
*4.23
( Obtain more accurate results ) In computing the following series, you will obtain
more accurate results by computing from right to left rather than from left to right:
1
2 +
1
3 + c +
1
n
1
+
Write a program that computes the results of the summation of the preceding
series from left to right and from right to left with n = 50000 .
*4.24
( Sum a series ) Write a program to sum the following series:
1
3 +
3
5 +
5
7 +
7
9 +
9
11 +
11
13 + c +
95
97 +
97
99
VideoNote
Sum a series
 
Search WWH ::




Custom Search