So I am stuck on my assignment where I am suppose to make mortgage calculator and I am suppose to do the following things:

1. Mortgage Calculator : prompts the user for (a) principal, (b) Annual interest rate , (c) number of months.It calculates the monthly payment and prints the summary of the mortgage.

2. Loan estimator : base on (a)monthly payment one is willing to pay (b)annual interest rate, and (c) terms in number of months , it calculates the maximum affordable loan amount.

3.Credit card minimum payment system : base on the credit card debt, annual interest rate , and the minimum payment for each month, it calculates the number of payments (months) it takes to pay-off the credit carddebt.

I was given a header file:

```
class Mortgage{
private :
double principal ; // amount
double apr ; // annual rate
int term ; // terms in number of month
double payment ;
public :
double get_principal() { return principal;};
double get_apr () { return apr ; } ;
double get_payment() {return payment ; };
int get_term() { return term; } ;
double calc_payment(double P, double rate, int term); // calculate the monthly payment
double estimate(double pay, double rate, int term) ; // estimate the max loan
void display() ; // print out the summary of the mortgage
double total(); // compute total interest paid
// constructors
Mortgage(double principal, double rate , int term) ;
Mortgage(Mortgage & mtg) ; // copy constructor
Mortgage(double dummy, double rate, int term, double monthly_payment) ; // for the use of option 2
Mortgage() ; // default constructor
} ;
double Mortgage::calc_payment(double P, double rate, int term){
return P * ((rate * (pow(( 1+ rate ), term)) / (pow((1 + rate), term) - 1)));
};
Mortgage::Mortgage(double principal, double rate, int term){
double mortgage;
double pay = 0.0;
mortgage = pay * ((pow((1+rate),(term))-1)/((rate*(pow((1+rate),(term))))));
}
```

and now I am suppose to implement 3 functions that fulfills the above listed requirements. This is the code I have so far:

```
#include "stdafx.h"
#include<iostream>
#include<cmath>
#include<iomanip>
#include "mortgage.h"
using namespace std;
void process();
void maxLoan();
void debt();
void display();
double calc_payment(double P, double rate, int term);
void estimate(double payment, double principal, double rate, int term);
void main_menu() {
printf("\n\tOptions:\n") ;
printf("\n\t1: Determine the monthly payment based on \n\t\tLoan amount, interest rate and terms.\n") ;
printf("\n\t2: Determine the maximum Loan amount based on \n\t\tmonthly payment, interest rate and terms.\n") ;
printf("\n\t3: Determine the total interest paid based on \n\t\tDebt amount,monthly payment and rate .\n") ;
printf("\n\t0: Quit \n") ;
}
int _tmain(int argc, _TCHAR* argv[])
{
int choice;
char resp[10];
printf("\n\t\tWelcome to CSC262 Financial Computing System!!\n") ;
while(true) {
main_menu();
while(true){
printf("\n\t\tYour choice is: ") ;
cin >> choice ;
if ( choice < 0 || choice > 3 ) {
printf("\n%d is an invalid choice!") ;
printf("\nPlease enter your choice 0, 1, 2 or 3 :") ;
}
else break;
}
switch (choice) {
case 1: process();
break;
case 2: maxLoan();
break;
case 3: debt();
break;
case 0: printf ("\n\nThank you for using CSC262 Financial Computing System!\n\n");
return 0;
break;
}
printf("\nWant to continue: (Y/N)? ");
cin >> resp;
if ( resp[0] == 'Y' || resp[0] == 'y') continue;
else break;
}
//display();
printf("\n\nThank you for using the CSC 262 Financial Computing System!!!\n\n");
return 0;
}
void process(){ // process option 1 : determine Monthly mortgage payment
int term ;
double principal , rate ;
double total_interest = 0.0 ;
//char resp[10];
double payment = 0.0;
cout << "\n\tPlease enter the Loan amount in $ :" ;
cin >> principal ;
cout << "\n\tPlease enter the interest rate (e.g 4.5 for 4.5%) :" ;
cin >> rate ;
cout << "\n\tPlease enter the terms in # of months :" ;
cin >> term ;
Mortgage mortgage(principal, rate, term);
display();
}
/*double calc_payment(double P, double rate, int term)
{
double payment;
payment = P * ((rate*pow((1+rate),(term)))/(pow((1+rate),(term))-1));
return payment;
}*/
void estimate(double payment, double principal, double rate, int term)
{
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 < term; i++) { // print each payment
double to_interest = principal * rate; // periodic interest
double to_principal = payment - to_interest; // principal part of payment
principal -= (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;
}
void display() {
double principal = 0.0;
double rate = 0.0;
double payment = 0.0;
int term = 0;
char resp[10];
cout << "\nMortgage Summary : \n\n";
cout << "Principal : " << principal;
cout << "\nAnnual Rate : " << rate << "%\n";
cout << "Term : " << term << "\n";
cout << "Monthly Payment : " << payment << "\n\n";
printf("Do you want to print the payment table? (Y/N) ");
cin >> resp;
if ( resp[0] == 'Y' || resp[0] == 'y')
estimate(payment, principal, rate, term);
else return;
}
void maxLoan(){
double rate , pay , MaxLoan;
int term;
cout << "\n\tPlease enter the monthly payment you feel comfortable with : ";
cin >> pay ;
cout << "\n Please enter the interest rate : " ;
cin >> rate;
cout << "\n Please enter the term in # of months : ";
cin >> term;
MaxLoan = pay * (pow((1+rate),(term))-1)/(rate*(pow((1+rate),(term))));
cout << "\n The maximum loan will be : " << MaxLoan;
}
void debt(){ // process option 3
double principal = 0.0;
double rate = 0.0;
double total_interest = 0.0 ;
double payment = 0.0 ;
double interest = 0.0 ;
int n = 0 ;
cout << "\nPlease enter the debt amount in Dollars : " ;
cin >> principal;
cout << "\nPlease enter the interest rate : " ;
cin >> rate;
double remain = principal ;
if ( remain > 0 ){
interest = remain * (rate/1200) ;
total_interest += interest ;
n++ ;
remain -= payment - interest ;
}
else {
exit(0);
}
//return remain;
cout << "\nThe total interest you will have to payoff is: " << remain << endl;
}
```

The problem is that none of my functions are working correctly. I am mainly having issues with the calculations. Could anyone please help me solve this issue?