Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

as an external function. I made two files for this. a calctaxes.c and a calctaxe

ID: 3627102 • Letter: A

Question

as an external function.

I made two files for this. a calctaxes.c and a calctaxes.h files. then i created a make file. When I am enter the command "make" it creates the object file. However when trying to make a .exe file so that the program will run i keep getting error messages! What am i doing wrong? can someone help me and perhaps even show me how to make it right? I'll show you what i have in my calctaxes.c file and what i have in the calctaxes.h. I'll also show my makefile.

calctaxes.c

#include "./calctaxes.h"
//prototype
void CalculateTaxes(float gross,float defr,float *ft,float *st,float *ssi); //3.5 CalculateTaxes
float CalcFedTax(float gross,float defr); //3.5.1 CalculateFedTax
float CalcStateTax(float ft); // 3.5.2 CalculateStatetax
float CalcSSITax(float gross,float defr); //3.5.3 CalculateSSItax
//main
void CalculateTaxes(float gross,float defr,float *ft,float *st,float *ssi)
{
*ft = CalcFedTax(gross, defr);//3.5.1
*st = CalcStateTax(*ft);//3.5.2
*ssi = CalcSSITax(gross, defr);//3.5.3
}
//functions
float CalcFedTax(float gross,float defr)
{
return (gross-defr)*FEDTAXRATE;
}//3.5.1
float CalcStateTax(float ft)
{
return (ft * STATETAXRATE);
}//3.5.2
float CalcSSITax(float gross,float defr)
{
return (gross-defr)*SSITAXRATE;
}//3.5.3


calctaxes.h

#define FEDTAXRATE 0.15
#define STATETAXRATE 0.07
#define SSITAXRATE 0.0775

makefile

2.o: calctaxes.c
gcc -c calctaxes.c -o 2.o
2.exe: calctaxes.h 2.o
gcc calctaxes.c 2.o -o 2.exe

can someone help me? I'm using a linux based system to make this and compile it. I'm a true beginner (started this about 4 weeks ago), and i'm still trying to work out the kinks. Can anyone help me please? If there is something terribly wrong with it, would it be possible to write me out the proper code so to get it compiled and running? thanks!


Explanation / Answer

Dear,
The following changes are marked with red color

cal.h

#define FEDTAXRATE 0.15
#define STATETAXRATE 0.07
#define SSITAXRATE 0.0775



caltaxes.c
#include ".calc.h" //prototype
void CalculateTaxes(float gross,float defr,float *ft,float *st,float *ssi); //3.5 CalculateTaxes
float CalcFedTax(float gross,float defr); //3.5.1 CalculateFedTax
float CalcStateTax(float ft); // 3.5.2 CalculateStatetax
float CalcSSITax(float gross,float defr); //3.5.3 CalculateSSItax
//main
void main()
{
//declare three variables of float type ft,st,ssi float ft,st,ssi;
//you need to pass the arguments and references to the pointers of ft,st,ssi.

CalculateTaxes(25000.0,550.0,&ft,&st,&ssi);
//you get result to the console
printf("ft=%.2f ",ft);
printf("st=%.2f ",st);
printf("ssi=%.2f",ssi); }

void CalculateTaxes(float gross,float defr,float *ft,float *st,float *ssi)
{
*ft = CalcFedTax(gross, defr);//3.5.1
*st = CalcStateTax(*ft);//3.5.2
*ssi = CalcSSITax(gross,defr);//3.5.3
}
//functions
float CalcFedTax(float gross,float defr)
{
return (gross-defr)*FEDTAXRATE;
}//3.5.1
float CalcStateTax(float ft)
{
return (ft * STATETAXRATE);
}//3.5.2
float CalcSSITax(float gross,float defr)
{
return (gross-defr)*SSITAXRATE;
}//3.5.3
gcc calctaxes.c
Hope this will help you