#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
using std::cout;
using std::cin;
using std::endl;
using std::string;
using std::setprecision;
using std::fixed;
//function prototypes
void getInput(string &, double);
void calcFedTaxes(double , double, double &, double &);
void calcnetPay(double &, double , double, double);
void displayInfo(string, double, double, double);
int main()
{
//declare constants and variables
const double FWT_RATE = .2;
const double FICA_RATE = .08;
string dname = "";
double dsalary = 0.0;
double dfwtTax = 0.0;
double dficaTax = 0.0;
double dnetPay = 0.0;
//display output in fixed-point notation with two decimal places
cout << fixed << setprecision(2);
//call function to get input and calculate salary and taxes
void getInput(string dname, double dsalary, double dnetPay);
void calcFedTaxes(double Fsalary, double FwtRate, double FicaRate,
double & withholdingTax, double & incomeTax);
void calcnetPay(double & netPay, double weeklySalary, double fwtTax,
double ficaTax);
void displayInfo (string dname, double dfwtTax, double dficaTax,
double dnetPay);
system ("pause");
} //end call function
//*****function definitions*****
void getInput(string iname, double isalary)
{
//enter input items
cout << "Enter name: ";
cin >> iname;
cout << "weekly salary: ";
cin >> isalary;
}
void calcFedTaxes (double Fsalary, double FwtRate, double FicaRate,
double & withholdingTax, double & incomeTax)
{
withholdingTax = Fsalary * FwtRate;
incomeTax = Fsalary * FicaRate;
}
void calcnetPay(double & netPay, double weeklySalary, double fwtTax,
double ficaTax)
{
netPay = weeklySalary - fwtTax - ficaTax;
}
void displayInfo(string dname, double dfwtTax, double dficaTax,
double dnetPay)
{
cout << "name: " << dname;
cout << "With holding Tax: " << dfwtTax;
cout << "With holding Fica: "<<dficaTax;
cout << "Net pay: " <<dnetPay;
cin>> dnetPay;
//end of displayInfo function
return;
}
views:
228answers:
5These aren't standard library functions, do you know where they come from - probably something in your environment/compiler.
You need to link with the libraries, in visual studio see properties->linker->input->additional dependencies, on uinx you will have to pass '-lnameoflibrary' to the compiler
Your code is referencing functions which it does not provide. (That's only a link error because those functions may well be provided by some other library you might be linking with.)
(without any code posted) You presumably have a separate header file which defines prototypes of getInput and displayInfo. Make sure that your definitions of getInput and displayInfo actually match those prototypes! Note that
void getInput(std::string &foo, double &bar)
is different than
void getInput(std::string foo, double bar)
and also, of course,
void getInpoot(std::string &foo, double &bar)
In main
,
//call function to get input and calculate salary and taxes
void getInput(string dname, double dsalary, double dnetPay);
void calcFedTaxes(double Fsalary, double FwtRate, double FicaRate,
double & withholdingTax, double & incomeTax);
void calcnetPay(double & netPay, double weeklySalary, double fwtTax,
double ficaTax);
void displayInfo (string dname, double dfwtTax, double dficaTax,
double dnetPay);
does not do what you think it does.
What you have done is given prototypes for functions. This generates no code and does not call any functions.
You probably meant
// call functions to get input and calculate salary and taxes
getInput(dname, dsalary, dnetPay);
double withholdingTax, incomeTax;
calcFedTaxes(dsalary, FWT_RATE, FICA_RATE, withholdingTax, incomeTax);
et cetera. These functions that you are trying to call do not match the functions you have actually defined, which you must also fix.
Just from a casual glance, I notice two obvious mistakes.
The first is an argument mismatch between the prototype and definition of getInput()
void getInput(string &, double &) ;
void getInput(string iname , double isalary)
where the prototype is expecting references, but the definition is not.
The second one is a bit more obvious once you see it. A simple typo where the function name is missing an "a" in the displayInfo()
definition.
void displyInfo(string dname, double dfwtTax, double dficaTax,
double dnetPay)
In main(), you are only prototype functions, not calling them:
//call function to get input and calculate salary and taxes
void getInput(string dname, double dsalary, double dnetPay);
That defines a function, now you need to call it:
getInput(dname, dsalary, dnetPay);
That said, your code is confusing. Let's look at the three current references to getInput in your code:
void getInput(string &, double);
void getInput(string dname, double dsalary, double dnetPay);
void getInput(string iname, double isalary) { ... }
You have two prototypes, both of which have different signatures then your function definition. Until you get that cleaned up, you are going to continue having trouble.