you will be completing part of the MortgageCalc class. The MortgageCalc class is a class containing static
Question:
you will be completing part of the MortgageCalc class. The MortgageCalc class is a class containing static methods to help calculate elements related to home loans, such as a payment calculator, principal payment calculator, and a remaining principal balance calculator. You will write two methods of the class.
public class MortgageCalc {
/**
* This method calculates the monthly payments for a mortgage payment
* @param principal Initial amount of the loan
* @param numPayments number of months in the loan
* @return the monthly payment for the loan
*/
public static double payment(double principal, int numPayments)
{
/* To Be implemented in part A */
}
/**
* This method returns the remaining balance for a given month
* in the loan.
* @param originalBal original balance of the loan
* @param numPayments original number of months in the loan
* @param currPeriod the month to calculate the remaining balance
* @return the remaining balance on the loan
*/
public static double remainingPrincipal(double originalBal, int numPayments, int currPeriod)
{
/* To be implemented in part B */
}
/**
* This method returns the current annual interest rate
* @return decimal value of the annual interest rate
* example: 4% interest is returned as 0.04
*/
public static double currentRate()
{
/* Implementation not shown */
}
/**
* This method returns the amount of principal paid for a given month
* in the loan.
* @param originalBal original balance of the loan
* @param numPayments original number of months in the loan
* @param currPeriod the month to calculate the principal payment
* @return the amount of the payment that is applied to the
* principal balance for the currPeriod
*/
public static double principalPayment(double originalBal, int numPayments, int currPeriod)
{
/* Implementation not shown */
}
}
1.
Write the static method payment which takes the initial amount of the loan (principal) and the number of payments (in months) and returns the monthly payment as a double.
To calculate the payment, you will also need the monthly interest rate, which can be calculated from the static currentRate() method that returns the current annual interest rate.
The formula for calculating the payment is:
CoursHeroTranscribedTextIncome Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill