Please help, I keep getting error C2664: 'State_Tax' : Cannot convert parameter 1 from 'float *' 'to float'

#include <stdio.h>
	#include <stdlib.h>
	#include <string.h>
	#include "./myheader.h"

void Calculate_Taxes(float gross, float deferred, float *federaltax,
			         float *statetax, float *ssitax);

float Federal_Tax(float deferred, float gross);
float State_Tax(float federaltax);
float SSI_Tax(float gross, float deferred);

void Calculate_Taxes(float gross, float deferred, float *federaltax,
					float *statetax, float *ssitax)
{
	*federaltax = Federal_Tax(gross, deferred);
    *statetax = State_Tax(federaltax);
	*ssitax = SSI_Tax(gross, deferred);
}

float Federal_Tax(float gross, float deferred)
{
	return (gross - deferred)*FEDTAXRATE;
}

float State_Tax(float federaltax)
{
	return (federaltax)*STATETAXRATE;
}

float SSI_Tax(float gross, float deferred)
{
	return (gross - deferred)*SSITAXRATE;
}

Recommended Answers

All 5 Replies

State_Tax is expecting float, you are passing float*.
Change *statetax = State_Tax(federaltax); to *statetax = State_Tax(*federaltax);

Look at the parameter for State_Tax() -- it is not a pointer. But you are trying to pass a pointer in Calculate_Taxes(). Change it to this: *statetax = State_Tax(*federaltax);

Alright now that thing is fixed, but I got 2 more errors now

error LNK2019: unresolved external symbol "void __cdecl CalcTaxesExt(float,float,float *,float *,float *)" (?CalcTaxesExt@@YAXMMPAM00@Z) referenced in function _main
fatal error LNK1120: 1 unresolved externals

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "./myheader.h"

void InputEmployeeData(char*lastname, char*firstname,
                             float*hours, float*payrate, float*deferred);     //3.3

float CalcGross(float hours, float payrate);                               //3.4

extern void CalcTaxesExt(float gross, float deferred, float *federaltax,
              float *statetax, float *ssitax);                            //3.5

void CalcNetPay(float gross, float deferred, float federaltax,
           float statetax, float ssitax, float*netpay);

void AddDetailToAccumulators(float hours, float*reghrs, float*ovthrs);
                                                      //3.6
void showReport(FILE*reportfile, char lastname[15+1], char firstname[10+1],
                    float payrate, float reghrs, float gross,
                    float federaltax, float ssitax, float netpay,
                    float ovthrs, float statetax, float deferred);            //3.7

int main(void)
{
  FILE * reportfile;

  int counter;
  float gross, federaltax,statetax,ssitax,hours, payrate, deferred,
	  reghrs, ovthrs, netpay, totrate, totreg, totgross,
        totfedtax, totssitax, totnet,
        totovt, totstate, totdeferred;

  char lastname[15+1],firstname[10+1], combinedName[25+1];


  reportfile = fopen("./report.txt","wt");
  if (reportfile == NULL)
  {
      printf(" Error opening report file ...\n");
      fflush(stdin);
      getchar();
      exit(-20);
  }
  fprintf(reportfile,REPORTHEADING1);
  fprintf(reportfile,REPORTHEADING2);
  fprintf(reportfile,REPORTHEADING3);
  for (counter=0; counter < MAX; counter++)
  {
      InputEmployeeData(lastname,firstname,&hours,&payrate,&deferred);
      AddDetailToAccumulators(hours,&reghrs,&ovthrs);
      gross = CalcGross(hours,payrate);
      CalcTaxesExt(gross,deferred,&federaltax,&statetax,&ssitax);
      CalcNetPay(gross,deferred,federaltax,statetax,ssitax,&netpay);
      strcpy(combinedName,lastname);
      strcat(combinedName, ", ");
      strcat(combinedName,firstname);
      fprintf(reportfile,REPORTFORMAT1,combinedName,payrate,
                          reghrs,gross,federaltax,ssitax,netpay);
      fprintf(reportfile,REPORTFORMAT2,ovthrs,statetax,deferred);
  }

  fclose(reportfile);
  fflush(stdin);
  getchar();
  return 0;
}

//functions

void showReport(FILE*reportfile, char lastname[15+1], char firstname[10+1],
              float payrate, float reghrs, float gross, 
              float fedtax, float ssitax, float netpay,
              float ovthrs, float statetax, float deferred);


void InputEmployeeData(char*lastname, char*firstname,
               float*hours, float*payrate, float*deferred)
{
   printf("    Enter Employee's Last and First Name  :  \n");
   scanf("%s%s",lastname,firstname);
   printf("    Enter Hourly Pay Rate                 :  \n");
   scanf("%f",payrate);
   printf("    Enter Total Hours Worked This Period  :  \n");
   scanf("%f",hours);
   printf("    Enter Amount of Deferred Earnings     :  \n");
   scanf("%f",deferred);
}


void AddDetailToAccumulators(float hours, float*reghrs, float*ovthrs)
{
  if (hours <= 40)
    *reghrs = hours,
    *ovthrs = 0.00;
  else
    *reghrs = 40.00,
    *ovthrs = (hours-40);
}

void CalcNetPay(float gross, float deferred, float fedtax,
           float statetax, float ssitax, float*netpay)
{
  *netpay = (gross-(deferred+fedtax+statetax+ssitax));
}

float CalcGross(float hours, float payrate)
{
  if (hours <= 40)
     return hours * payrate;
  else
     return 40 * payrate + (hours-40) * 1.5 * payrate;
}

It seems to be caused my main

"unresolved externals" means the linker can not locate the named function. In this case it is looking for CalcTaxesEx() and can not find it. Check the code you posted and you will see that it isn't there.

ahh i see, my mistake

Thanks

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.