i am supposed to have 2 void functions and 4 value returning functions (including main) to eventually calculate netsalary from calling the specific functions to calculate tax and insurance and receive and display data.... basically i'm wondering what is my error (compiled in dev and couldn't figure out what was wrong with the particular lines)
here's what i did:-

#include <iostream>
#include <string>
#include <iomanip>

using namespace std;

void getInput(string &, double&);
double calcFwt(double, double );
double calcFica(double, double );
double calcNetPay(double, double, double, double );
void displayInfo(string, double, double, double);

int main ()
{
    string name = " ";
    double wkPay = 0.00;
    double fwt = 0.00;
    double fica = 0.00;
    double netPay = 0.00;
    
    cout << fixed << setprecision (2);
    
    getInput (name, wkPay);
    fwt = calcFwt (wkPay, fwt);
    fica = calcFica (wkPay, fica);
    netPay = calcNetPay (wkPay, fwt, fica, netPay);
    displayInfo (name, fwt, fica, netPay);

void getInput (string & name,  double & wkPay);
     {
              cout << "Customer name: ";
              getline (cin, name);
              cout << "Enter customer weekly salary: ";
              cin >> wkPay;
     }     
    
double calcFwt (double wkPay, double fwt);
       {
               return fwt = 0.20 * wkPay;
       }

double calcFica (double wkPay, double fica);
       {
                return fica = 0.08 * wkPay;
       }

double calcNetPay (double wkPay, double fwt, double fica, double netPay);
       {
                  return netPay = wkPay - (fica + fwt);
       }

void displayInfo (string & name, double & fwt, double & fica, double & netPay);
     {
                 cout << "Customer name: " << name << endl;
                 cout << "FWT is: " << fwt << endl;
                 cout << "FICA is: " << fica << endl;
                 cout << "Net Pay is: " << netPay << endl;
     }

}

Recommended Answers

All 4 Replies

What are the specific errors that you got (the first 5-10 are good for now). Also, I see you tried on the code tags but it has to be

[code]

//code here

[/code]

These are wrong :

double calcFwt (double wkPay, double fwt);
       {
               return fwt = 0.20 * wkPay;
       }
 
double calcFica (double wkPay, double fica);
       {
                return fica = 0.08 * wkPay;
       }
 
double calcNetPay (double wkPay, double fwt, double fica, double netPay);
       {
                  return netPay = wkPay - (fica + fwt);
       }

There are at least 2 things wrong with each function. Try to find out that
it is.

Move curly brace from line 60 to line 28. As it is all your functions are implemented inside main.

Remove the semi-column at the end of lines
29,37,42,47 & 52. these are implementation signatures.

Change the returns as previously suggested.

Add a line to do the operation first and then do the return.

netPay = wkPay - (fica + fwt);
return netPay;

thank you very much i forgot to come back on and say i got it to work !!:D
thanks guys

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.