Im getting fatal errors... can anyone help me edit my program!
Posted
by user350217
on Stack Overflow
See other posts from Stack Overflow
or by user350217
Published on 2010-06-01T07:57:01Z
Indexed on
2010/06/01
8:03 UTC
Read the original article
Hit count: 407
visual-c++
The errors i am getting are:
Error 1 error LNK2019: unresolved external symbol "double __cdecl getDollarAmt(void)" (? getDollarAmt@@YANXZ) referenced in function _main hid.obj Error 2 fatal error LNK1120: 1 unresolved externals
this is my program:
#include<iostream>
#include<cmath>
#include<string>
using namespace std;
double getDollarAmt();
void displayCurrencies();
char getCurrencySelection (float amtExchanged);
bool isSelectionValid(char selection);
double calcExchangeAmt (float amtExchanged, char selection);
void displayResults(double newAmount, float amtExchanged, char selection, char yesNo);
const double russianRubles = 31.168;
const double northKoreanWon = .385;
const double chineseYuan = 6.832;
const double canadianDollar = 1.1137;
const double cubanPeso = 1.0;
const double ethiopianBirr = 9.09;
const double egyptianPound = 5.6275;
const double tunisianDinar = 1.3585;
const double thaiBaht = 34.4;
/******
I changed the variables to global variables so
you don't have to worry about accidentally setting them
to 0 or assigning over a value that you need
********/
float amtEchanged = 0.0;
char selection;
char yesNo;
double newAmount;
int main()
{
float amtExchanged = 0.0;
selection = 'a';
yesNo = 'y';
newAmount = 0.0;
getDollarAmt ();
displayCurrencies();
getCurrencySelection (amtExchanged);
isSelectionValid(selection);/**** you only need to use the selection variable ****/
calcExchangeAmt (amtExchanged, selection);
displayResults(newAmount, amtExchanged, selection, yesNo);
return 0;
}
double getDollarAmt (float amtExchanged)
// promt user for eachange amount and return it to main
{
float amtExchanged0;//created temporary variable to set amtExchanged to
cout<< "Please enter the total dollar amount to exchange: ";
cin>> amtExchanged0;
amtExchanged = amtExchanged0;//setting amtExchanged to the right value
return amtExchanged;
}
void displayCurrencies()
// display list of currencies
{
cout<<"A Russian Ruble"<<endl
<<"B North Korean Won"<<endl
<<"C Chinese Yuan"<<endl
<<"D Cuban Peso"<<endl
<<"E Ethiopian Birr"<<endl
<<"F Thai Baht"<<endl
<<"G Canadian Dollars"<<endl
<<"H Tunisian Dinar"<<endl
<<"I Egyptian Pound"<<endl;
}
char getCurrencySelection (float amtExchanged)
// make a selection and return to main
{
char selection0;//again, created a temporary variable for selection
cout<<"Please enter your selection: ";
cin>>selection0;
selection = selection0;//setting the temporary variable to the actual variable you use
/*****
we are now going to see if isSelectionValid returns false.
if it returns false, that means that their selection was not
character A-H. if it is false we keep calling getCurrencySelection
*****/
if(isSelectionValid(selection)==false)
{
cout<<"Sorry, the selection you chose is invalid."<<endl;
getCurrencySelection(amtExchanged);
}
return selection;
}
bool isSelectionValid(char selection)
// this fuction is supposed to be called from getCurrencySelection, the selction
// must be sent to isSelectionValid to determine if its valid
// if selection is valid send it bac to getCurrencySelection
// if it is false then it is returned to getCurrencySelection and prompted to
// make another selection until the selection is valid, then it is returned to main.
{
/****
i'm not sure if this is what you mean,
all i am doing is making sure
that their selection is A-H
*****/
if(selection=='A' || selection=='B' || selection=='C' || selection=='D' || selection=='E' || selection=='F' || selection=='G' || selection=='H' || selection=='I')
return true;
else
return false;
}
double calcExchangeAmt (float amtExchanged,char selection)
// function calculates the amount of money to be exchanged
{
switch (toupper(selection))
{
case 'A': newAmount =(russianRubles) * (amtExchanged);
break;
case 'B': newAmount = (northKoreanWon) * (amtExchanged);
break;
case 'C': newAmount = (chineseYuan) * (amtExchanged);
break;
case 'D': newAmount = (canadianDollar) * (amtExchanged);
break;
case 'E': newAmount = (cubanPeso) * (amtExchanged);
break;
case 'F': newAmount = (ethiopianBirr) * (amtExchanged);
break;
case 'G': newAmount = (egyptianPound) * (amtExchanged);
break;
case 'H': newAmount = (tunisianDinar) * (amtExchanged);
break;
case 'I': newAmount = (thaiBaht) * (amtExchanged);
break;
}
return newAmount;
}
void displayResults(double newAmount, float amtExchanged, char selection, char yesNo)
// displays results and asked to repeat. IF they want to repeat it clears the screen and starts over.
{
switch(toupper(selection))
{
case 'A': cout<<"$"<<amtExchanged<<" is "<<newAmount<<" Russian Rubles."<<endl<<endl;
break;
case 'B': cout<<"$"<<amtExchanged<<" is "<<newAmount<<" North Korean Won."<<endl<<endl;
break;
case 'C': cout<<"$"<<amtExchanged<<" is "<<newAmount<<" Chinese Yuan."<<endl<<endl;
break;
case 'D': cout<<"$"<<amtExchanged<<" is "<<newAmount<<" Cuban Pesos."<<endl<<endl;
break;
case 'E': cout<<"$"<<amtExchanged<<" is "<<newAmount<<" Ethiopian Birr."<<endl<<endl;
break;
case 'F': cout<<"$"<<amtExchanged<<" is "<<newAmount<<" Thai Baht."<<endl<<endl;
break;
case 'G': cout<<"$"<<amtExchanged<<" is "<<newAmount<<" Canadian Dollars."<<endl<<endl;
break;
case 'H': cout<<"$"<<amtExchanged<<" is "<<newAmount<<" Tunisian Dinar."<<endl<<endl;
break;
case 'I': cout<<"$"<<amtExchanged<<" is "<<newAmount<<" Egyptian Pound."<<endl<<endl;
break;
}
cout<<"Do you wish to continue? (Y for Yes / N for No)";
cin>>yesNo;
if(yesNo=='y' || yesNo=='Y')
{
getDollarAmt();
}
else
{
system("cls");
}
}
© Stack Overflow or respective owner