Modular Programming

I fixed all the obvious errors that it gave me, now i have 3 errors that i do not know how to solve.

ERRORS
Severity Code Description Project File Line
1.Error LNK1120 1 unresolved externals
2.Error LNK2019 unresolved external symbol "void __cdecl showResult(float,float,float,float)" (?showResult@@YAXMMMM@Z) referenced in function _main
3.Error LNK2005 _main already defined in source file (Lab 3).

#include <iostream>
using namespace std;
//function declarations
float getPurchaseAmount();
float calculateStateTax (float purchaseAmount);
float calculateCountyTax (float purchaseAmount);
float calculateTotalSalesTax (float stateTax, float countyTax);
float calculateTotalSale (float totalSalesTax, float purchaseAmount);
void showResult (float purchaseAmount, float stateTax, float countyTax, float totalSalesTax);

//Declare constants
const float STATE_RATE = 0.04f;
const float COUNTY_RATE = 0.02f;

int main() // start of the main function

{
//Declare and initialize variables
float purchaseAmount = 0;
float stateTax = 0;
float countyTax = 0;
float totalSalesTax = 0;
float totalSale = 0;


// Get PurchaseAmount
purchaseAmount = getPurchaseAmount();

//Get State Tax
stateTax= calculateStateTax (purchaseAmount);

//Get County Tax
countyTax = calculateCountyTax (purchaseAmount);

// Get total Sales tax
totalSalesTax = calculateTotalSalesTax(stateTax, countyTax);

// Get total sale
totalSale = calculateTotalSale(totalSalesTax, purchaseAmount);

// Display results
showResult(purchaseAmount,stateTax, countyTax,totalSalesTax);

char quitKey;
//Delay
cout << "Press any key and Enter to end program: ";
cin >> quitKey;

//End of Program
return 0;
}

//Function to display purchase amount
float getPurchaseAmount()
{
float purchaseAmount;
cout << "Enter the amount of purchase and press ENTER" << endl;
cin >> purchaseAmount;
//return result
return purchaseAmount;
}


// Function to Calculate state tax
float calculateStateTax(float purchaseAmount)
{
//Decxlare variables for state tax
float stateTax;
//Calculate State tax
stateTax = STATE_RATE * purchaseAmount;
//return result
return stateTax;
}

//Function to Calculate County tax
float calculateCountyTax(float purchaseAmount)
{
//Declare variables for county tax
float countyTax;
//Calculate County tax
countyTax = COUNTY_RATE * purchaseAmount;
//return result
return countyTax;
}

//Function to calculate total sales tax
float calculateTotalSalesTax(float stateTax, float countyTax)
{
float totalSalesTax;
//Calculate total sales tax
totalSalesTax = stateTax + countyTax;
// return result
return totalSalesTax;
}
// Function to calculate total sale
float calculateTotalSale(float totalSalesTax, float purchaseAmount)
{
float totalSale;

//Calculate total sale
totalSale = totalSalesTax + purchaseAmount;

// return result
return totalSale;
}

void showResult(float purchaseAmount, float stateTax, float countyTax, float totalSalesTax,float totalSale)
{
//Display all the purchase amount, state tax, county tax, total tax, and total of sale
cout << "Purchase amount = " << purchaseAmount << endl;
cout << "State tax = " << stateTax << endl;
cout << "County tax = " << countyTax << endl;
cout << "Total tax = " << totalSalesTax << endl;
cout << "Total of sale = " << totalSale << endl;
}
First of all, use code tags, see the button with <> on the right
The error message complains about the definition/implementation of showResult function:
In the definition you have
void showResult (float purchaseAmount, float stateTax, float countyTax, float totalSalesTax);
In the implementation:
void showResult(float purchaseAmount, float stateTax, float countyTax, float totalSalesTax,float totalSale)
Did you notice that the number of parameters is different?
Last edited on
Oh wow! how could i not have caught that! yes i see it!
Topic archived. No new replies allowed.