-1

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;
}
BenMorel
  • 34,448
  • 50
  • 182
  • 322
tinywolves
  • 55
  • 1
  • 3
  • 10
  • 1
    possible duplicate of [error LNK2019 unresolved external symbol](http://stackoverflow.com/questions/12297952/error-lnk2019-unresolved-external-symbol) and about three dozen others. A search for "error LNK2019: unresolved external symbol" would have turned up many links to previous questions. It's good to do basic research first before posting. – Ken White Mar 07 '14 at 03:48
  • 1
    I did I searched this forum and I understand the error but after an hour couldn't find the error in MY code. I didn't see the capitalization mistake. Other people's coding errors couldn't help me. – tinywolves Mar 07 '14 at 03:56
  • 1
    OK, it should be closed as off-topic because "This question was caused by a problem that can no longer be reproduced or **a simple typographical error**. While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers. This can often be avoided by identifying and closely inspecting the shortest program necessary to reproduce the problem before posting. " – Ken White Mar 07 '14 at 11:52

3 Answers3

2

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.

OSborn
  • 895
  • 4
  • 10
2

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

Cigany
  • 178
  • 1
  • 10
1
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.

cf-
  • 8,598
  • 9
  • 36
  • 58
  • OH MY GOD. TWO HOURS FOR A CAPITALIZATION ERROR I couldn't see. I cannot believe you noticed this. Yeah it worked. Wow. – tinywolves Mar 07 '14 at 03:49
  • @user3390939 Just for future reference, this sort of linker error usually means this sort of typo happened. It usually means either the definition's name doesn't match the declaration's name, or the types of the parameters in the definition don't match the types of the parameters in the declaration. – cf- Mar 07 '14 at 03:56