I am attempting to compile an early version of a loan calculator for a project. However, I am getting an error I cannot understand. LNK2019 and LNK1120.
I am new at c++ and coding in general so hopefully this doesn't come across as a dumb question. I am coming from a intro to programming class in c not c++. I appreciate any help I can receive. I am using virtual studio 2022 community edition.
#include <fstream>
#include <string>
#include <iomanip>
using std::cout;
using std::endl;
using std::cin;
void welcome();
double getPrincipal();
double getTerm();
double getAnnualRate();
double convertRate();
double CalcPayment();
void DisplayResults(double, double, double, double);
int main()
{
double loanPrincipal(0);
double termLength(0);
double annualIntRate(0);
double monthlyIntRate(0);
double MonPayment(0);
welcome();
loanPrincipal = getPrincipal();
termLength = getTerm();
annualIntRate = getAnnualRate();
monthlyIntRate = convertRate();
MonPayment = CalcPayment();
DisplayResults(loanPrincipal, termLength, annualIntRate, MonPayment);
return 0;
}
#include <iostream>
#include <string>
#include <iomanip>
//welcomes the user
void welcome()
{
cout << "Welcome to the ammortization loan calculator" << endl;
cout << "" << endl;
}
//asks the user for amount of loan
double getPrincipal()
{
double userPrinicpal = 0;
cout << "Please enter the loan ammount that you wish to borrow: " << endl;
double userPrincipal;
cin >> userPrincipal;
return userPrincipal;
}
//asks the user for the annual interest rate
double getAnnualRate(double annualIntRate)
{
cout << "Please enter the annual interest rate: " << endl;
cin >> annualIntRate;
return annualIntRate;
}
double convertRate(const double annualIntRate)
{
double MonIntRate;
MonIntRate = (annualIntRate / 100) / 12;
return MonIntRate;
}
//asks the user for the length of the loan
void getTerm(int& termLength)
{
cout << "Please enter the length of the loan (10, 15, or 30 years)" << endl;
cin >> termLength;
}
//calculate monthly payment
double CalcPayment(double loanPrincipal, double monthlyIntRate, int termLength)
{
double MonPayment = loanPrincipal * (monthlyIntRate * (1 + monthlyIntRate) * 180) / ((1 + 0.00375) * 180 - 1);
return MonPayment;
}
//display results from previous calculations to the user
void DisplayResults(double loanPrincipal, double termLength, double annualIntRate, double MonPayment)
{
cout << "Loan Application - Amortization Schedule" << endl;
cout << "" << endl;
cout << "Principal: " << loanPrincipal << endl;
cout << "Life of Loan: " << termLength << endl;
cout << "Annual interest rate: " << annualIntRate << endl;
cout << "Monthly Payment: " << MonPayment << endl;
}
Error LNK2019 unresolved external symbol "double __cdecl getTerm(void)" (?getTerm@@YANXZ) referenced in function main
Error LNK2019 unresolved external symbol "double __cdecl getAnnualRate(void)" (?getAnnualRate@@YANXZ) referenced in function main
Error LNK2019 unresolved external symbol "double __cdecl convertRate(void)" (?convertRate@@YANXZ) referenced in function
Error LNK2019 unresolved external symbol "double __cdecl CalcPayment(void)" (?CalcPayment@@YANXZ) referenced in function
Error LNK1120 4 unresolved externals