Hi, I'm new to C++. Can someone solve this ? i had been building it correctly but when the time execute, the problem pop out. Here is my code.
#include <iostream>
#include <iomanip>
using namespace std;
// function prototype
double getInput(double a,double b);
double calculate(double a, double b,double c);
void displayStatement(double a, double b);
void printResults(double c);
void calculateMoney(double&c, double& amountLeft, double rm50, double rm10, double rm5, double rm1, double cent50, double cent20, double cent10, double cent5);
void displayAmount (double rm50, double rm10, double rm5, double rm1, double cent50, double cent20, double cent10, double cent5);
int main(void)
{
double total = 0;
double amountPaid=0;
double change=0;
double amountLeft=0;
double rm50=0, rm10=0, rm5=0, rm1=0, cent50=0, cent20=0, cent10=0, cent5=0;
getInput(total, amountPaid);
calculate(total, amountPaid, change);
displayStatement(total, amountPaid);
printResults(change);
calculateMoney(change, amountLeft, rm50, rm10, rm5, rm1, cent50, cent20, cent10, cent5);
displayAmount(rm50, rm10, rm5, rm1, cent50, cent20, cent10, cent5);
}
double get_input_from_users(double a, double b)
{
cout << " Please Enter the total and paid amount : " << "RM";
cin >> a >> b;
return a, b;
}
double calculate_results(double a, double b, double c)
{
c = b - a;
return c;
}
void display_statement(double a, double b)
{
cout << setw(38) << "*****STATEMENT*****" << endl;
cout << "Total" << setw(44) << "RM " << a << endl;
cout << "Paid Amount" << setw(38) << "RM " << b << endl;
cout << "----------------------------------------------------" << endl;
return;
}
void printResutls(double c)
{
cout << "Change " << setw(42) << "RM " << c << endl;
cout << "\nThe amount " << c << " consists of " << endl;
}
void calculateMoney(double& c, double& amountLeft, double rm50, double rm10, double rm5, double rm1, double cent50, double cent20, double cent10, double cent5)
{
rm50 = c / 50;
amountLeft = c - 50;
rm10 = amountLeft / 10;
amountLeft = amountLeft - 10;
rm5 = amountLeft / 5;
amountLeft = amountLeft - 5;
rm1 = amountLeft / 1;
amountLeft = amountLeft - 1;
cent50 = amountLeft / 0.5;
amountLeft = amountLeft - 0.5;
cent20 = amountLeft / 0.20;
amountLeft = amountLeft - 0.20;
cent10 = amountLeft / 0.10;
amountLeft = amountLeft - 0.10;
cent5 = amountLeft / 0.05;
amountLeft = amountLeft - 0.05;
return;
}
void displayAmount(double rm50, double rm10, double rm5, double rm1, double cent50, double cent20, double cent10, double cent5)
{
cout << "riggit 50 " << setw(20) << rm50 << endl;
cout << "riggit 10 " << setw(20) << rm10 << endl;
cout << "riggit 5 " << setw(21) << rm5 << endl;
cout << "riggit 1 " << setw(21) << rm1 << endl;
cout << "50 cents " << setw(21) << cent50 << endl;
cout << "20 cents " << setw(21) << cent20 << endl;
cout << "10 cents " << setw(21) << cent10 << endl;
cout << "5 cents " << setw(22) << cent5 << endl;
return;
}
And the error list:
Error 5 error LNK1120: 4 unresolved externals C:\Users\Jack\Desktop\Selfcoding\Debug\Selfcoding.exe 1 1 Selfcoding
Error 2 error LNK2019: unresolved external symbol "double __cdecl calculate(double,double,double)" (?calculate@@YANNNN@Z) referenced in function _main C:\Users\Jack\Desktop\Selfcoding\Selfcoding\exam1.obj Selfcoding
Error 1 error LNK2019: unresolved external symbol "double __cdecl getInput(double,double)" (?getInput@@YANNN@Z) referenced in function _main C:\Users\Jack\Desktop\Selfcoding\Selfcoding\exam1.obj Selfcoding
Error 3 error LNK2019: unresolved external symbol "void __cdecl displayStatement(double,double)" (?displayStatement@@YAXNN@Z) referenced in function _main C:\Users\Jack\Desktop\Selfcoding\Selfcoding\exam1.obj Selfcoding
Error 4 error LNK2019: unresolved external symbol "void __cdecl printResults(double)" (?printResults@@YAXN@Z) referenced in function _main C:\Users\Jack\Desktop\Selfcoding\Selfcoding\exam1.obj Selfcoding
Can someone please help me? I will be appreciated!