Question: Hey, I need some help with Java Programming. My homework is to write a program that prompts the user for L, n, and i, and
Hey, I need some help with Java Programming. My homework is to write a program that prompts the user for L, n, and i, and display the resulting value of P.
Description: If one takes out a loan for L dollars, at an annual interest rate of I percent, for a term of N years, then the monthly payment, P, for the loan can be calculated using the following formula: P = (r * L) / ( 1 (1 + r)-n) Where r = i / 12 is the monthly interest rate and n = 12 * N is the number of months of the loan. As an example, if $10,000 is borrowed for 5 years (n would be 60 in the above formula) at an annual interest rate of 5.5% (i would be 0.55 and r would be 0.055 / 12 in the above formula), then the monthly payment would be $ 191.01.
Task: You must use a programmer- defined class method for performing the calculation and you must use a built-in Java Math class method for calculating the part of the formula with exponent. Use the java.text.DecimalFormat class to express the payment amount to two decimal places as follows: java.text.DecimalFormat df = new java.text.DecimalFormat(#####.##); df.format(p); // return value of P with two decimal places.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
