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 solutionChapter 5 Solutions
Introduction to Java Programming and Data Structures Comprehensive Version (11th 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)
- Language: JAVA Leap-Year Write a program to find if a year is a leap year or not. We generally assume that if a year number is divisible by 4 it is a leap year. But it is not the only case. A year is a leap year if − It is evenly divisible by 100 If it is divisible by 100, then it should also be divisible by 400 Except this, all other years evenly divisible by 4 are leap years. So the leap year algorithm is, given the year number Y, Check if Y is divisible by 4 but not 100, DISPLAY "leap year" Check if Y is divisible by 400, DISPLAY "leap year" Otherwise, DISPLAY "not leap year" For this program you have to take the input, that is the year number from an input file input.txt that is provided to you. The input file contains multiple input year numbers. Use a while loop to input the year numbers from the input file one at a time and check if that year is a leap year or not. Create a class named LeapYear which will contain the main method and write all your code in the main…arrow_forwardPlease read the instructions carefully: This is a Java programarrow_forwardPlease read the instructions carefully: This is a Java programarrow_forward
- write the code using javaarrow_forwardX3: inlTo10 Write a function in Java that implements the following logic: Given a number n, return true if n is in the range 1..10, inclusive. Unless "outsideMode" is true, in which case return true if the number is less or equal to 1, or greater or equal to 10.arrow_forwardnbm.m//,//arrow_forward
- X15: inOrder Write a function in Java that implements the following logic: Given three ints, a, b , and c,return true if b is greater than a, and c is greater than b.However, with the exception that if bok is true, b does not need to be greater than a.arrow_forward7) The ideal gas law allows the calculation of volume of a gas given the pressure(P), amount ofthe gas (n), and the temperature (T). The equation is:V = nRT / PSince we only have used integer arithmetic, all numbers will be integer values with nodecimal points. The constant R is 8.314 and will be specified as (8314/1000). This givesthe same result. Implement the idea gas law program where the user is prompted for andenters values for n, T, and P, and V is calculated and printed out. Be careful toimplement an accurate version of this program. Your program should include a properand useful prompt for input, and print the results in a meaningful mannerarrow_forwardJAVA:arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning