
For the formula to compute monthly payment, see Listing 2.9, ComputeLoan.java.
**5.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
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 as follows:
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);
}

Want to see the full answer?
Check out a sample textbook solution
Chapter 5 Solutions
Introduction to Java Programming and Data Structures: Brief Version (11th Global Edition)
Additional Engineering Textbook Solutions
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Mechanics of Materials (10th Edition)
Problem Solving with C++ (10th Edition)
Java: An Introduction to Problem Solving and Programming (8th Edition)
SURVEY OF OPERATING SYSTEMS
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,EBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT




