too few arguments

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
double compute_taxes(double gpay)
{
       double gross;
       double td;  // to hold the tax deduction
       if (gross <= 1000)
          td = gross * 0.5;
       else if(gross < 1500)
            td= gross * 0.6;
       else
           td= gross * 0.7;
}
double compute_npay(double gpay)
{
       double gross;
       double npay, td;   
       compute_taxes();
       npay = gpay - td;
} 


Write the function double compute_npay(double gpay) that receives an employee's gross pay using the value parameter gpay, computes the net pay and returns it. the net pay is the gross pay - the tax deduction. To compute the net pay, it first calls compute_taxes() to compute the tax deduction.
Last edited on
line 2: too few arguments to function 'double compute_taxes(double)'
line 16: at this point in file
The error tells you exactly what the problem is are where it is. What don't you understand about it?
wow im sorry, i just dont know whats wrong with it, sorry
the compute taxes function takes an argument double gpay
on line 16 you call compute_taxes();
By only using () and nothing inside of the parenthesis, you are passing no arguments.
just because "gpay" is visible to compute_npay, does not mean that comput_taxes sees it.
you need to compute_taxes(gpay);

Also your function does not return a value

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
double compute_taxes(double gpay)
{
      // double gross; //Im guessing you mean gpay, but do not redefine it
       if (gpay <= 1000)
          return  gpay * 0.5;
       else if(gpay < 1500)
            return  gpay * 0.6;
       else
           return gpay * 0.7;
}

double compute_npay(double gpay)
{
       //double gross;  Unused
       double npay, td;   
       td = compute_taxes(gpay);
       npay = gpay - td;
       return npay; //Probably what you need to do here

} 
Last edited on
Topic archived. No new replies allowed.