please write by JAVA Write a program that will output a table of monthly payment
ID: 3596076 • Letter: P
Question
please write by JAVA
Write a program that will output a table of monthly payments from an initial loan amount over a range of 15 to 30 years in 5 year increments for several different interest rates. This program is an exercise in formatting output. One can compute a monthly payment based on the initial loan amount, annual percentage rate, and loan duration in years. The monthly payment is calculated using this formula: m=Pr (1+ry 11ry 1) Where m is the monthly payment, P, is the initial loan amount, and ris the monthly interest rate. The monthly interest rate is the annual percentage rate divided by 12; r= APR/12. The value n is the number of payment periods, n = number of years times 12 months/year. Use these inputs: • $100,000.00 (as the initial loan amount 3% (representing the low annual- interest rate of 3%) 6% (representing the high annual-interest rate of 6%) Your program will calculate and print a table showing the resulting monthly payment based on the loan amountloan interest rates, and duration of the loan. The interest rates will be displayed from the low rate to the high rate in increments of 1/2 percent (5%). The duration of the loan will be for periods of 15, 20, 25, and 30 years, Table of monthly payments for a dollar loan amount of $100000.00 Years: 15 20 25 30 XXX.XX XXX. XX XXX.XX XXX.XX XXXXX XXX.XX XXX.XX 3.08 3.58 4.08 4.58 5.08 5.58 6.08 XXXXX XXX.XX XXX.XX XXX.XX XXXXX XXX. XX XXX.XX XXX.XX XXX, XX XXX.XX XXXXX XXXXX XXX.XX XXX. XXExplanation / Answer
import java.io.*;
import java.lang.*;
import java.util.*;
public class DemoFormat{
public static void main(String[] args){
System.out.printf("%10s %10s %10s %10s %10s ","Years","15","20","25","30");
double intr = 3.0;
for (double i = 3.0; i<6.5; i=i+0.5){
System.out.printf(" %10s ",i);
for (double j=15; j<35; j=j+5){
double m = (100000.00 *i/1200*Math.pow(1+i/1200,j*12))/(Math.pow(1+i/1200,j*12)-1);
System.out.printf("%10.2f ",m);
}
}
System.out.println();
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.