Write a program that creates a loan amortization table. The user of the program
ID: 3628490 • Letter: W
Question
Write a program that creates a loan amortization table. The user of the program will supply values for Initial Loan Principal, Annual Percentage Rate and Monthly Payment. The program should print out the appropriate amortization table including the Number of Monthly Payments and the Total Interest Paid for the life of the loan. The program should allow multiple runs of the table process and should allow the user to compare runs in a tabular format (at least 4 different versions of the amortization table) at the end of the program execution. Key data from each amortization table that should be displayed in the comparison table are Initial Principle, Initial Payment, Annual Percentage Rate, Total Number of Payments and Total Interest Paid.Explanation / Answer
please rate - thanks
import java.util.*;
public class amortization
{public static void main(String [] args)
{double principal, rate, mrate, mpay, factor, interest=0,totint=0,mint;
int month=0, cnt=1,runs=0;
int[] totPay=new int[10];
double[] initPrin=new double[10];
double[] initPay=new double[10];
double[] aRate=new double[10];
double[] totInt=new double[10];
char again='y';
String input;
Scanner in=new Scanner(System.in);
do{cnt=1;
System.out.print("Enter the principal of the loan: ");
principal=in.nextDouble();
System.out.print("What is the monthly payment? ");
mpay=in.nextDouble();
System.out.print("What is the Annual Interest Rate? ");
rate=in.nextDouble();
initPrin[runs]=principal;
initPay[runs]=mpay;
aRate[runs]=rate;
System.out.printf("Principal: $ %.2f ",principal);
System.out.printf("Annual Interest Rate: %.2f%% ",rate);
System.out.printf("Monthly Payment: %.2f ",mpay);
System.out.printf("Payment Interest Principal Balance ");
while(principal>mpay)
{interest=principal*((rate/100)/12);
totint+=interest;
System.out.printf("%3d %7.2f %7.2f",cnt,interest,principal);
principal=principal+interest-mpay;
System.out.printf(" %7.2f ",principal);
cnt++;
}
interest=principal*((rate/100)/12);
totint+=interest;
System.out.printf("Final Payment: $%6.2f ",principal+interest);
System.out.printf("Total interest paid $%6.2f ",totint);
System.out.println("Total number of payments: "+(cnt));
totPay[runs]=cnt;
totInt[runs]=totint;
runs++;
if(runs<4)
{System.out.print(" Do you have another set of data(Y/N)? ");
input=in.next();
again=Character.toUpperCase(input.charAt(0));
}
}while(runs<4&&again=='Y');
System.out.println("Loan comparison ");
for(int i=0;i<runs;i++)
{System.out.printf("principal %d: $%6.2f ",(i+1),initPrin[i]);
System.out.printf("payment %d: $%6.2f ",(i+1),initPay[i]);
System.out.printf("rate %d: $%6.2f ",(i+1),aRate[i]);
System.out.printf("total payments %d: %d ",(i+1),totPay[i]);
System.out.printf("total interest %d: $%6.2f ",(i+1),totInt[i]);
System.out.println();
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.