Ive been working on a solution to my homework problem for a couple hours and I believe I have found the answer but I keep getting this error code

>Hw_3.obj : error LNK2019: unresolved external symbol "void __cdecl printTable(double,double,double,int)" (?printTable@@YAXNNNH@Z) referenced in function "void __cdecl process(void)" (?process@@YAXXZ)
1>Hw_3.obj : error LNK2019: unresolved external symbol "public: __thiscall Mortgage::Mortgage(double,double,int)" (??0Mortgage@@QAE@NNH@Z) referenced in function "void __cdecl process(void)" (?process@@YAXXZ)

#include<iostream>
#include<cmath>
#include<iomanip>

#include "Mortgage.h"

using namespace std;


void process() ;
void maxLoan() ;
void debt() ;
double calc_payment(double Loan, double rate, int term);
void printTable(double payment, double Loan, 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 main()
{

int choice ;
char resp[10];

printf("\n\t\tWelcome to CSC262 Mortgage Calculator System!!\n") ;

while(true) {

main_menu() ;

while(true) {

printf("\n\t\tYour choice is: ") ;
cin >> choice ;
if ( choice < 1 || choice > 3 ) {
printf("\n%d is an invalid choice!") ;
printf("\nPlease enter your choice 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 mortgage calculator System!\n\n") ;
return 0;
break ;
}

printf("\n\tWant to to continue? (Y/N)") ;
cin >> resp;
if ( resp[0] == 'Y' || resp[0] == 'y') continue ;
else break ;


}
printf("\n\nThank you for using CSC262 mortgage calculator System!\n\n") ;

return 0;
}

 


void process()
{ // process option 1 : determine Monthly mortgage payment

int term ;
double Loan , rate ;
double total_interest = 0.0 ;
char resp[10] ;
double payment;



cout << "\n\tPlease enter the Loan amount in $ :" ;
cin >> Loan ;
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 mtg(Loan, rate, term);




double calc_payment(double Loan, double rate, int term);
{
	payment = Loan * ((rate*pow((1+rate),(term)))/(pow((1+rate),(term))-1));
}

void printTable(double payment, double Loan, 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 = Loan * rate;		// periodic interest
		double to_principal = payment - to_interest;	// principal part of payment

		Loan -= (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();
{
	cout << "Mortgage Summary : \n\n";
	cout << "Principal : " << Loan;
	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')
		printTable(payment, Loan, 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 Loan , rate ;
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 >> Loan;

cout << "\nPlease enter the interest rate : " ;
	cin >> rate;

// put your code here ;

// main logic for determine the # of payment in order to pay-off

 double remain = Loan ;
 while ( remain > 0 ){
 interest = remain * rate/1200 ;
 total_interest += interest ;
 n++ ;
 remain -= payment - interest ;

 }

}

I know some of the logic that makes the calculator work might be messed up but I am just trying to figure out how to fix the error, any help is greatly appreciated.

You shouldn't have semicolons after your function definitions on 102,107,and 131.

process() should have a closing brace somewhere.

Line 97 will declare a Mortgage object that will be destroyed after process() completes (once you put a closing brace at the end of the function).

You shouldn't have semicolons after your function definitions on 102,107,and 131.

process() should have a closing brace somewhere.

Line 97 will declare a Mortgage object that will be destroyed after process() completes (once you put a closing brace at the end of the function).

Thanks for the speedy reply, I changed some things around and deleted the semi colons, however I'm still getting the 2nd error message

1>Hw_3.obj : error LNK2019: unresolved external symbol "public: __thiscall Mortgage::Mortgage(double,double,int)" (??0Mortgage@@QAE@NNH@Z) referenced in function "void __cdecl process(void)" (?process@@YAXXZ)

I have my Mortgage class defined in a header file, I dont know if that is what is messing it up or not.

It's looking for the definition of the constructor for the Mortgage class. Is that in this file or in another one? If it's in another file, you need to be compiling the cpp files together (or make them part of the same project in your IDE).

There in the same project and at the top of my .cpp file I have #include "Mortgage.h"

Heres the header file

class Mortgage
{

     private : 
         double  Loan ;    // amount
         double  rate ;          // annual rate 
         int term ;             // terms in number of month
         double payment ;

     public :
         
         Mortgage();
         double get_Loan() ;
         double get_rate () ;
         double get_payment() ;
         int get_term() ;
                  
         double calc_payment();  // calculate the monthly payment
         void printTable();  // print the mortgage payment table
         void display() ;    // print out the summary of the mortgage
		
		
		
 Mortgage(double Loan, double rate , int term) ;   
 Mortgage(Mortgage & mtg) ;     // copy constructor
};

Why are you redefining the methods with different parameters on lines 13 and 14 of your prior listing? You need to define them with the proper parameters on lines 18 and 19 of the new listing. Then, you need to define the methods

Mortgage::Mortgage(double Loan,double rate,int term)
{
   constructor code here
}

double Mortgage::calc_payment(double yada1,double yada2,int yada3) 
{

}

It's probably a good idea to take a spin back through your text or your favorite online resource to refresh some of these concepts before trying to write the code. I know it seems like it will take more time, but if you have the concept down it will in fact go much more quickly.

I actually didnt write any of the Header file code, it was given to the class as part of the assignment, looks like this is going to be interesting.

The header file is fine. You could implement the method (function) definitions in the same file as main if you wanted to

#include "mortgage.h"

Mortgage::Mortgage(//params)
{

}

Mortgage::calcpayment(//params)
{

}

//more definitions

int main()
{


}

but people usually place the definitions for the class in one .cpp file and the main program in another.

It won't take you long, you just need to copy/paste some stuff around and make sure that your definitions match the declarations in the header.

You sir, are my hero.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.