|
From: <Tre...@ao...> - 2001-06-26 16:34:17
|
After compiling the following program and getting no errors, I tried to build
an executable and received external errors. Can anyone help me?
//T7AppE08.cpp - displays employee's name, FWT, FICA tax, and net pay
#include <iostream>
#include <string>
using namespace std;
//function prototypes
void getInput(string, float&);
float calcFwt(float, float);
float calcFica(float, float);
float calcNetPay(float, float, float);
void displayInfo(string, float, float, float, float);
int main()
{
const float FWT_RATE = float(.2);
const float FICA_RATE = float(.08);
string name = "";
float salary = 0.0;
float fwtTax = 0.0;
float ficaTax = 0.0;
float netPay = 0.0;
//enter input items
getInput(name, salary);
//calculate taxes
calcFwt(salary, FWT_RATE);
calcFica(salary, FICA_RATE);
//calculate net pay
calcNetPay(salary, fwtTax, ficaTax);
//display name, gross, taxes, and net
displayInfo(name, salary, fwtTax, ficaTax, netPay);
return 0;
} //end of main function
//*****program-defined functions*****
void getInput(string name, float salary)
{
cout << "Enter employee name: ";
getline(cin, name);
cout << "Enter weekly salary: ";
cin >> salary;
} //end of getInput function
float calcFwt(float salary, const float FWT_RATE, float fwtTax)
{
fwtTax = salary * FWT_RATE;
return fwtTax;
} //end of calcFwt function
float calcFica(float &salary, const float FICA_RATE, float ficaTax)
{
ficaTax = salary * FICA_RATE;
return ficaTax;
} //end of calcFica function
float calcNetPay(float salary, float fwtTax, float ficaTax, float netPay)
{
netPay = salary - (fwtTax + ficaTax);
return netPay;
} //end of calcNetPay function
void displayInfo(string &name, float salary, float fwtTax, float ficaTax,
float netPay)
{
cout << fixed;
cout.precision(2);
cout << "Employee name: " << name << endl;
cout << "Gross pay: $" << salary << endl;
cout << "FWT tax: $" << fwtTax << endl;
cout << "FICA tax: $" << ficaTax << endl;
cout << "Net pay: $" << netPay << endl;
} //end of displayInfo function
|
|
From: Nurhidayat <dh...@ma...> - 2001-06-27 07:40:36
|
I try to correct them. .. 1. I think the correct code is #include <iostream.h> not #include <iostream> 2. The prototype of: void getInput(string, float&); is not match to function declaration: void getInput(string name, float salary) Second parameter must be fixed to: float& salary 3. The same problem also causes of different prototypes to declarations. The other prototypes of: float calcFwt(float, float); float calcFica(float, float); float calcNetPay(float, float, float); void displayInfo(string, float, float, float, float); respectively are not match (type or number of parameters) to function declarations: float calcFwt(float salary, const float FWT_RATE, float fwtTax) float calcFica(float &salary, const float FICA_RATE, float ficaTax) float calcNetPay(float salary, float fwtTax, float ficaTax, float netPay) void displayInfo(string &name, float salary, float fwtTax, float ficaTax, float netPay) If it's hard to make them consistent, dont make prototypes. Just put your functions before main(). ___Nurhidayat___ |
|
From: Ray W. <ra...@in...> - 2001-06-27 19:15:01
|
You can use #include <iostream> without the ".h", but you have to follow it somewhere with a "using namespace std;" statement. This can be anywhere before you use any of the library function in iostream. The use of the namespace statement is the new C++ standard and is implemented in Dev C++. Note that only "using namespace std;" statement is required in the program reguardless of how many #include directives you use. At 02:37 PM 6/27/01 +0700, you wrote: >I try to correct them. .. > >1. I think the correct code is >#include <iostream.h> not #include <iostream> > >2. The prototype of: void getInput(string, float&); >is not match to function declaration: >void getInput(string name, float salary) >Second parameter must be fixed to: float& salary > >3. The same problem also causes of different prototypes to declarations. >The other prototypes of: >float calcFwt(float, float); >float calcFica(float, float); >float calcNetPay(float, float, float); >void displayInfo(string, float, float, float, float); > >respectively are not match (type or number of parameters) to function >declarations: >float calcFwt(float salary, const float FWT_RATE, float fwtTax) >float calcFica(float &salary, const float FICA_RATE, float ficaTax) >float calcNetPay(float salary, float fwtTax, float ficaTax, float netPay) >void displayInfo(string &name, float salary, float fwtTax, float ficaTax, >float netPay) > >If it's hard to make them consistent, dont make prototypes. Just put your >functions before main(). > > >___Nurhidayat___ > > > >_______________________________________________ >Dev-cpp-users mailing list >Dev...@li... >http://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > Ray Witter |
|
From: Ray W. <ra...@in...> - 2001-06-27 19:22:51
|
The following should have read "Note that only one "using namespace std;" statement is required ....." I left out the "one", changes meaning of sentence. Usually the namespace statement is placed immediatly after the #include directives, It does not have to be however, as long as it occurs before the library function calls. Sorry about typo. ray w. At 12:11 PM 6/27/01 -0700, you wrote: >You can use #include <iostream> without the ".h", but you have to >follow it somewhere with a "using namespace std;" statement. This >can be anywhere before you use any of the library function in iostream. The >use of the namespace statement is the new C++ standard >and is implemented in Dev C++. Note that only "using namespace std;" >statement is required in the program reguardless of how many #include >directives you use. > >At 02:37 PM 6/27/01 +0700, you wrote: >>I try to correct them. .. >> >>1. I think the correct code is >>#include <iostream.h> not #include <iostream> >> >>2. The prototype of: void getInput(string, float&); >>is not match to function declaration: >>void getInput(string name, float salary) >>Second parameter must be fixed to: float& salary >> >>3. The same problem also causes of different prototypes to declarations. >>The other prototypes of: >>float calcFwt(float, float); >>float calcFica(float, float); >>float calcNetPay(float, float, float); >>void displayInfo(string, float, float, float, float); >> >>respectively are not match (type or number of parameters) to function >>declarations: >>float calcFwt(float salary, const float FWT_RATE, float fwtTax) >>float calcFica(float &salary, const float FICA_RATE, float ficaTax) >>float calcNetPay(float salary, float fwtTax, float ficaTax, float netPay) >>void displayInfo(string &name, float salary, float fwtTax, float ficaTax, >>float netPay) >> >>If it's hard to make them consistent, dont make prototypes. Just put your >>functions before main(). >> >> >>___Nurhidayat___ >> >> >> >>_______________________________________________ >>Dev-cpp-users mailing list >>Dev...@li... >>http://lists.sourceforge.net/lists/listinfo/dev-cpp-users >> >> >Ray Witter > >_______________________________________________ >Dev-cpp-users mailing list >Dev...@li... >http://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > Ray Witter |