Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

import java.util.*; import java.io.*; import static java.lang.System.*; public class quiz{ public static void main(String args[])throws IOException { Scanner sc = new Scanner (System.in); System.out.println(Enter loan

import java.util.*; import java.io.*; import static java.lang.System.*; public class quiz{ public static void main(String args[])throws IOException { Scanner sc = new Scanner (System.in); System.out.println("Enter loan amount:"); double P = sc.nextDouble(); System.out.println("Enter nominal annual interest:"); double annualInterest = sc.nextDouble(); double r =annualInterest/12; System.out.println("Enter number of years for loan:"); int years = sc.nextInt(); int n = years*12; double pay = P*(r*Math.pow(1+r,n))/(Math.pow(1+r,n)-1); amortiziationScheduleHeader(P); for(int i =1; i<=n;i++) { double interestAmount = r*P; double principalAmount = pay-interestAmount; if((i%25 ==0) || (i==n)) amortiziationScheduleLine(i,pay,interestAmount,principalAmount,(P-principalAmount)); P-=principalAmount; } out.printf(" Amount of interest paid $%,.2f ",_________); } // Prints out the amortiziation schedule header -- do this only once public static void amortiziationScheduleHeader(double b) { out.printf("%s%7s%9s%10s%12s %,45.2f ","Payment","Amount","Interest","Principal","Balance",b); } // Prints out the amortiziation schedule per line -- call this in a loop public static void amortiziationScheduleLine(int x, double a, double b, double c, double d) { out.printf("%4d%,10.2f%,9.2f%,10.2f%,12.2f ", x,a,b,c,d); } } OUTPUT:

Enter loan amount: 20000 Enter nominal annual interest: 0.075 Enter number of years for loan: 5 Payment Amount Interest Principal Balance 20,000.00 25 400.76 80.52 320.24 12,563.33 50 400.76 26.55 374.21 3,873.20 60 400.76 2.49 398.27 0.00

Amount of interest paid $0.00

the part of the code that is bolded is missing something in order to have the output as "Amount of interest paid $4, 045.54" what is missing?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Driven Web Sites

Authors: Mike Morrison, Joline Morrison

1st Edition

061901556X, 978-0619015565

More Books

Students also viewed these Databases questions

Question

How do Data Types perform data validation?

Answered: 1 week ago

Question

How does Referential Integrity work?

Answered: 1 week ago