class MortgagePaymentCalculator{
// Fields private to the class
private float cMonthlyPayment;
private float cPrinciple;
private int cMonths;
private float cRate;
// Class constructor method
MortgagePaymentCalculator(float principle, float rate, int months)
{
// Set the class fields to the arguments.
cRate = rate;
cPrinciple = principle;
cMonths = months;
// Compute the monthly payment for the
// class field cMonthlyPayment.
computeMonthlyPayment();
}
// Method to return the monthly payment
float getMonthlyPayment()
{
return cMonthlyPayment;
}
// Computes the monthly payment but not accessible outside the class.
private computeMonthlyPayment()
{
// Compute cMonthlyPayment here using the
// cPrinciple, cMonths and cRate fields.
}
}