Heavy math SAT, GRE, (critical thinking) JAVA writing code question. NEED ANSWER
ID: 3809207 • Letter: H
Question
Heavy math SAT, GRE, (critical thinking) JAVA writing code question. NEED ANSWER. Please type solution or make sure to have readable writing. Also, the answer to the problem must work for any case and only testing input values should be used within main. PLEASE make a note how to do algebra and manipulation!
[Critical Thinking] Compute the monthly payment amount and total payoff amount of a loan given the initial amount, apr, and duration
of the loan (number of months).
a. Write a method that takes (amount of debt, apr, number of monthly payments) and returns the amount of each monthly payment.
b. Write a method that takes (amount of debt, apr, number of monthly payments) and returns the total amount paid to payoff the debt.
c. These methods are very similar to the previous two, but they are much more difficult to compute.
Explanation / Answer
class EMICalc
{
//a. Write a method that takes (amount of debt, apr, number of monthly payments)
//and returns the amount of each monthly payment.
double monthlyPaymentCalc(double amountOfDebt, double apr, int numOfPayments)
{
double eachMonthlyPayment = (apr * amountOfDebt) / (1 - Math.pow((1+apr), (-1*numOfPayments)));
eachMonthlyPayment = Math.floor(eachMonthlyPayment*100+0.5)/100;
eachMonthlyPayment = eachMonthlyPayment / 12;
System.out.println("Your monthly EMI is: " + eachMonthlyPayment);
return eachMonthlyPayment;
}
//b. Write a method that takes (amount of debt, apr, number of monthly payments)
//and returns the total amount paid to payoff the debt.
double totalAmountPaidOff(double amountOfDebt, double apr, int numOfPayments)
{
double totalAmount = monthlyPaymentCalc(amountOfDebt, apr, numOfPayments);
totalAmount = totalAmount * numOfPayments;
System.out.println("Your total amount to be paid off for this loan is: " + totalAmount);
return totalAmount;
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.