Give the project a meaningful name. Write a main method to test a new static met
ID: 3872382 • Letter: G
Question
Give the project a meaningful name. Write a main method to test a new static method used to compute a monthly payment on a loan. The new static method used to compute the monthly payment for a loan uses this formula: m = p_0 middot r middot (1 + r)^n ((1 + r)^n - 1) Where m is the monthly payment, P_0 is the initial loan amount, r is the monthly interest rate, and n is the number of monthly payments. The monthly interest rate is the Annual Percentage Rate divided by 12: r = APR/12. The number of payments, n, is 12 times the loan duration in years. The monthly payment on a $25000 loan over 6 years with an APR = 7% is $426.23. You should use the Math.pow (double base, double exponent) method for this exercise. Be sure to use descriptive names for all modules in this exercise.Explanation / Answer
class CalculateIntrest{
static int initialLoanAmount=25000;
static int numberOfMonths=72;
static double intrestRateperMonth=0.5833;
static double monthlyPayment;
public static double payment() {
monthlyPayment=(initialLoanAmount*intrestRateperMonth*Math.pow((1+intrestRateperMonth), numberOfMonths))/(Math.pow((1+intrestRateperMonth), numberOfMonths)-1);
return monthlyPayment;
}
}
public class LoanPayment {
public static void main(String[] args) {
// TODO Auto-generated method stub
double monthlyPayment=CalculateIntrest.payment();
System.out.println("The amount to be paid manthly is "+monthlyPayment);
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.