Please help me in this homework.

```
/* mortgage -- calculates the amount of a monthly mortgage payment based on the
* principal (i.e., the amount borrowed), the annual percentage rate (APR), and
* the number of years to payoff the loan. Prints an amortization schedule (table).
*
* The program assumes one payment per month (i.e., 1 period = 1 month).
* Therefore, the number of periods = the number of years * 12 and
* the periodic interest rate = APR / 12.
*/
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
// function prototypes (aka function declarations)
double calc_payment(double balance, double r, int n);
void printTable(double payment, double balance, double r, int n);
int main()
{
int years; // number of years of loan
double principal; // principal-- loan amount
double apr; // annual percentage rate
cerr << "Please enter the principal: ";
cin >> principal;
cerr << "Please enter the APR: ";
cin >> apr;
cerr << "Please enter the number of years: ";
cin >> years;
cout.setf(ios::fixed); // fixed point output
cout.precision(2); // two places after the .
int periods = years * 12; // convert years to periods
double p_rate = apr / 12; // convert APR to periodic rate
// periodic payment
double payment = calc_payment(principal, p_rate, periods);
cout << "Monthly Payment: " << payment << endl << endl;
printTable(payment, principal, p_rate, periods);
return 0;
}
// function calculates the periodic (i.e., monthly payment).
// example of a function that returns a value (it can be an expression).
double calc_payment(double principal, double r, int n)
{
return principal * r / (1 - pow(1 + r, -n));
}
// function prints an amortization schedule (table).
// example of a function that does not return a value (can only be a statement).
void printTable(double payment, double balance, double r, int n)
{
cout << setw(14) << "Interest" << setw(10) << "Principal" << endl;
cout << setw(14) << "--------" << setw(10) << "---------" << endl;
double total_principal = 0; // total of payments applied to principal
double total_interest = 0; // total of payments applied to interest
for (int i = 0; i < n; i++) // print each payment
{
double to_interest = balance * r; // periodic interest
double to_principal = payment - to_interest; // principal part of payment
balance -= (payment - to_interest);
total_interest += to_interest;
total_principal += to_principal;
cout << setw(3) << i + 1 << ":" <<
setw(10) << to_interest << setw(10) << to_principal << endl;
}
cout << endl << setw(14) << total_interest << setw(10) << total_principal << endl;
}
```

what I need just some adding to get like this when I do run for the programe.

```
Welcome to CSC309 Mortgage Calculator System!!
Options:
1: Determine the monthly payment based on
Loan amount, interest rate and terms.
2: Determine the maximum Loan amount based on
monthly payment, interest rate and terms.
3: Quit
Your choice is: 1
Please enter the Loan amount in $ :50000
Please enter the interest rate (e.g 4.5 for 4.5%) :5
Please enter the terms in # of months :60
Your monthly paymnent is $ 943.56
Your total interest will be $ 6613.70
Do you want to print the monthly report ? (Y/N) Y
Options :
1: Print the entire payment history.
2: Print the history of the first n payments.
3: Print the history of the last n payments.
4: Print the history between m-th and n-th payments.
Your choice is: (1 - 4) 2
Please enter the number of payments you want to print: 12
No. | Payment | Interest|Principal| Balance | Total Paid | Total Int
1 | $943.56 | $208.33 | $735.23 | $49264.77 | $943.56 | $208.33
2 | $943.56 | $205.27 | $738.29 | $48526.48 | $1887.12 | $413.60
3 | $943.56 | $202.19 | $741.37 | $47785.11 | $2830.69 | $615.80
4 | $943.56 | $199.10 | $744.46 | $47040.65 | $3774.25 | $814.90
5 | $943.56 | $196.00 | $747.56 | $46293.10 | $4717.81 | $1010.90
6 | $943.56 | $192.89 | $750.67 | $45542.42 | $5661.37 | $1203.79
7 | $943.56 | $189.76 | $753.80 | $44788.62 | $6604.93 | $1393.55
8 | $943.56 | $186.62 | $756.94 | $44031.68 | $7548.49 | $1580.17
9 | $943.56 | $183.47 | $760.10 | $43271.58 | $8492.06 | $1763.64
10 | $943.56 | $180.30 | $763.26 | $42508.32 | $9435.62 | $1943.94
11 | $943.56 | $177.12 | $766.44 | $41741.87 | $10379.18 | $2121.05
12 | $943.56 | $173.92 | $769.64 | $40972.24 | $11322.74 | $2294.98
Do you want to try other option? (Y/N)
```