/******************************************************************** Function Name: MortgageCalculator::reportMortgageDetails Function Description: displays the details of the mortgage the user has input **********************************************************************/ void MortgageCalculator::reportMortgageDetails() { // amortize a mortgage and get the monthly payment Mortgage mortgage = Mortgage(m_interestRate, m_term, m_principalAmount); const double monthlyPayment = mortgage.getMonthlyPayment(); const int numberOfPayments = mortgage.getNumberOfPayments(); // display a nice report to the user cout << endl << fixed << setprecision(2) // all numbers as fixed-point with 2 digits << setw(24) << left << "Term in Years:" << " " << setw(7) << right << m_term << endl << setw(24) << left << "Interest Rate:" << " " << setw(10) << right << m_interestRate << "%" << endl << setw(24) << left << "Mortgage Principal:" << "$" << setw(10) << right << m_principalAmount << endl << setw(24) << left << "Monthly Payment:" << "$" << setw(10) << right << monthlyPayment << endl << endl; // print a payment breakdown by month printBreakdownHeader(1, monthlyPayment); for (int month = 1; month <= numberOfPayments; month++) { const double interestPayment = mortgage.getInterestPayment(month); const double principalPayment = mortgage.getPrincipalPayment(month); const double remainingBalance = mortgage.getRemainingBalance(month); cout << setw(10) << right << month << " " << "$" << setw(10) << right << interestPayment << " " << "$" << setw(10) << right << principalPayment << " " << "$" << setw(10) << right << remainingBalance << endl; // pause and print a new header every year if ((month % Mortgage::MONTHS_IN_YEAR) == 0 && month < numberOfPayments) { pausePrompt(); printBreakdownHeader(month / Mortgage::MONTHS_IN_YEAR + 1, monthlyPayment); } } }
/******************************************************************** Function Name: MortgageCalculator::reportMortgageDetails Function Description: displays the details of the mortgage the user has input **********************************************************************/ void MortgageCalculator::reportMortgageDetails() { // amortize a mortgage and get the monthly payment Mortgage mortgage = Mortgage(m_principalAmount, m_interestRate, m_term); const double monthlyPayment = mortgage.getMonthlyPayment(); // display a nice report tot he user cout << endl << fixed << setprecision(2) // all numbers as fixed-point with 2 digits << setw(24) << left << "Term in Years:" << " " << setw(7) << right << m_term << endl << setw(24) << left << "Interest Rate:" << " " << setw(10) << right << m_interestRate << "%" << endl << setw(24) << left << "Mortgage Principal:" << "$" << setw(10) << right << m_principalAmount << endl << setw(24) << left << "Monthly Payment:" << "$" << setw(10) << right << monthlyPayment << endl << endl; }