Question

I'm getting this error: error LNK2019: unresolved external symbol "double __cdecl calculateRetail(double,double)" (?calculateRetail@@YANNN@Z) referenced in function _main 1>c:\users\100236744\documents\visual studio 2010\Projects\Item sales price calculator\Debug\Item sales price calculator.exe : fatal error LNK1120: 1 unresolved externals

I am very new to c++.

// FILE: Price markup calculator.cpp
// PROGRAMMER: Karolina Sabat   CPSC 1103   Section: S11
// Program which calculates the retail cost of an item based on wholesale cost and mark up percentage. 
// Calculates the total interest paid based on the annual interest rate.

#include <iostream>         // For cin, cout
#include <iomanip>          // For setw, setprecision
using namespace std;

// FUNCTION PROTOTYPES
void getData (double &, double &);          // Receives USER INPUT - Wholesale cost & percentage markup
double calculateRetail(double, double);     // Calculates retail price
void Display (double, double, double);      // Displays results: Wholesale cost, markup percentage, retail price

int main ()
{

// VARIABLES
double  wholesale_cost = 0;                 // Wholesale item cost - USER INPUT
double  markup_percent = 0;                 // Markup percentage
double  retail_price = 0;               // Calculated retail cost

// FUNCTION CALL 1: Wholesale cost - USER INPUT
getData(wholesale_cost, markup_percent);
// FUNCTION CALL 2: Retail price - CALCULATION
calculateRetail(wholesale_cost, markup_percent); 
// FUNCTION CALL 3: Display Wholesale price, markup percentage, retail price - OUTPUT
Display(wholesale_cost, markup_percent, retail_price);
// PROGRAM MADE BY - OUTPUT
cout << endl << endl;
cout << " Written by: Karolina Sabat - CPSC 1103 - Section: S11" << endl << endl;
 return 0;
 }

// FUNCTION 1: GetData
void getData (double &wholesale_c, double &markup_p)
{
// Wholesale cost - USER INPUT
cout << " Please enter the item's wholesale cost: $ ";
cin >> wholesale_c;
// Wholesale cost - INVALID ENTRY 
while (wholesale_c < 0)
{
    cout << endl;
    cout << " Please enter a wholesale cost greater than 0." << endl;
    cout << " Item's wholesale cost: $ ";
    // Will clear characters
    cin.clear();
    cin.ignore(numeric_limits<streamsize>::max(), '\n');
    cin >> wholesale_c;
}
// Wholesalecost - VALID
// Markup percentage - USER INPUT
cout << "Please enter the markup percentage: % " ;
cin >> markup_p;
// Markup percentage - INVALID
while (markup_p < 0) 
{
    cout << " ERROR: INVALID INPUT." << endl;
    cout << " Please enter a markup percentage greater than 0." << endl;
    cout << " Markup percentage: % ";
    // Will clear characters
    cin.clear();
    cin.ignore(numeric_limits<streamsize>::max(), '\n');
    cin >> markup_p;
}
}

// FUNCTION 2: CalculateRetail
double CalculateRetail (double wholesale_c, double markup_p)
{
// VARIABLES
double markup_amount;
double retail_price;
// CALCULATIONS
markup_amount = (wholesale_c * markup_p) / 100;
// Markup amount
retail_price = wholesale_c + markup_amount;
return retail_price;
}

// FUNCTION 3: Display
void Display (double wholesale_cost, double markup_percent, double retail_price)
{
// Title - OUTPUT
cout << endl;
cout << " WHOLESALE COST: " << setw(10) << "PRICE MARKUP %: " << setw(10) << "RETAIL PRICE" << endl;
cout << " ________________________________________________________________________________" << endl;
cout << endl;
// NUMBER FORMATING
cout << setprecision(2) << fixed << showpoint;
// Results - OUTPUT
cout << " " << wholesale_cost << setw(10) << markup_percent << setw(10) << retail_price;
}
Was it helpful?

Solution

You are experiencing this issue because your wrote the prototype for the function as:

double calculateRetail(double, double);

but then when you implemented the function, you wrote:

double CalculateRetail (double wholesale_c, double markup_p)

C and C++ are case sensitive so it doesn't see CalculateRetail and calculateRetail as the same. You probably meant to write CalculateRetail as calculateRetail.

OTHER TIPS

calculateRetail delacred and used. CalculateRetail defined. ...... c != C

double calculateRetail(double, double);

double CalculateRetail (double wholesale_c, double markup_p)

Your function definition doesn't exactly match its prototype. If you change the defined name to calculateRetail, it should work.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top