Re: one more try on C programming help

  • From: "John Miller" <n1umj@xxxxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Tue, 30 Oct 2007 18:49:55 -0400

OK, here's the code and the list of errors. I did what I thought might fix some of it but it made no difference, maybe someone else can see what's goign on, based on the errors and what I've seen so far this semester, it's probably 1 thing I missing, maybe more than once but very likely it's only 1 or 2 things over all I'm missing to get this decent. code as is right now follows with errors following.


#include <stdio.h>

/* function prototypes */

void initData(emp, SIZE);

float calculateOverTime(int entry, float *wagePtr,float *hoursWorkedPtr);

float calculateGrossPay(int entry, float *wagePtr,float *hoursWorkedPtr);

void displayEntry(int entry, int *clockNumberPtr,float *wagePtr,float *hoursWorkedPtr);


struct emp;

int main (char *argv, int argc)

{ /*get clock info*/

int clockNumber; /*employee number*/

float wage; /* declare wage */

float hoursWorked; /*enter hours worked*/

int i=0;//index for for loop

initData(clockNumber,wage,hoursWorked);

for (i=0;i<5;i++)

getHoursWorked(i,clockNumber,hoursWorked);

printf("Clock #\tWAge\thours\tOver time\tGross Pay\n");

for (i=0;i<5;i++)

displayEntry(i,clockNumber,wage,hoursWorked);

struct emp myempArray[5];

return(0);

} /*end get clock info*/

struct emp;

void initData(int *clockNumberPtr,float *wagePtr,float *hoursWorkedPtr)

{ /* declaring clock numbers and wage*/

int i; // index for for loop

emp[0].clockNumber=98401; /*first employee*/

emp[1].clockNumber=526488; /* second employee*/

emp[2].clockNumber=765349; /*third employee */

emp[3].clockNumber=34645; /*forth employee*/

emp[4].clockNumber=127615; /*fifth employee */

emp[0].wage=10.60; /* first employee wage

emp[1].wage=9.75; /*second employee wage

emp[2].wage=10.50; /* third employee wage */

emp[3].wage=12.25; /*employee 4 wage */

emp[4].wage=8.35; /* fifth employee wage 8/

// init hours worked to 0

for (i=0;i<5;i++)

hoursWorkedPtr[i]=0;

} /*end declaring clock and wage numbers*/

void getHoursWorked(struct employee emp[])

{ /*prompt for hours*/

printf ("Enter hours worked by %d: ",clockNumberPtr[entry]);

scanf_s("%f", &(hoursWorkedPtr[entry]));

} /*end prompt for hours*/

float calculateOverTime(int entry, float *wagePtr,float *hoursWorkedPtr)

{ /* figure out overtime */

float overTimeHours=hoursWorkedPtr[entry]-40;

float overTimePay=0;

if (overTimeHours>0)

overTimePay=overTimeHours*(wagePtr[entry]*1.5);

return (overTimePay);

} /* end figuring out overtime */



float calculateGrossPay(int entry, float *wagePtr,float *hoursWorkedPtr)

{ /* determine gross pay*/

float grossPay=0;

if (hoursWorkedPtr[entry]>40)

grossPay=(40*wagePtr[entry])+calculateOverTime(entry,wagePtr,hoursWorkedPtr);

else

grossPay=wagePtr[entry]*hoursWorkedPtr[entry];

return (grossPay);

} /*end determine gross pay */

void displayEntry(int entry, int *clockNumberPtr,float *wagePtr,float *hoursWorkedPtr)

{ /*desplay results */

printf ("%d\t%0.2f\t%0.2f\t%0.2f\t%0.2f\n",

emp.clockNumber,

emp.wage,

emp.hoursWorked,

calculateOverTime(entry,wagePtr,hoursWorkedPtr),

calculateGrossPay(entry,wagePtr,hoursWorkedPtr));

} /* end desplay output*/



errorw,



Warning 1 warning C4013: 'getHoursWorked' undefined; assuming extern returning int c:\documents and settings\john miller\my documents\visual studio 2005\projects\homework6\homework6.c 36 Warning 2 warning C4047: 'function' : 'int *' differs in levels of indirection from 'int' c:\documents and settings\john miller\my documents\visual studio 2005\projects\homework6\homework6.c 40 Warning 3 warning C4024: 'displayEntry' : different types for formal and actual parameter 2 c:\documents and settings\john miller\my documents\visual studio 2005\projects\homework6\homework6.c 40 Error 4 error C2440: 'function' : cannot convert from 'float' to 'float *' c:\documents and settings\john miller\my documents\visual studio 2005\projects\homework6\homework6.c 40 Warning 5 warning C4024: 'displayEntry' : different types for formal and actual parameter 3 c:\documents and settings\john miller\my documents\visual studio 2005\projects\homework6\homework6.c 40 Error 6 error C2440: 'function' : cannot convert from 'float' to 'float *' c:\documents and settings\john miller\my documents\visual studio 2005\projects\homework6\homework6.c 40 Warning 7 warning C4024: 'displayEntry' : different types for formal and actual parameter 4 c:\documents and settings\john miller\my documents\visual studio 2005\projects\homework6\homework6.c 40 Error 8 error C2143: syntax error : missing ';' before 'type' c:\documents and settings\john miller\my documents\visual studio 2005\projects\homework6\homework6.c 41 Error 9 error C2065: 'emp' : undeclared identifier c:\documents and settings\john miller\my documents\visual studio 2005\projects\homework6\homework6.c 51 Error 10 error C2109: subscript requires array or pointer type c:\documents and settings\john miller\my documents\visual studio 2005\projects\homework6\homework6.c 51 Error 11 error C2109: subscript requires array or pointer type c:\documents and settings\john miller\my documents\visual studio 2005\projects\homework6\homework6.c 52 Error 12 error C2109: subscript requires array or pointer type c:\documents and settings\john miller\my documents\visual studio 2005\projects\homework6\homework6.c 53 Error 13 error C2109: subscript requires array or pointer type c:\documents and settings\john miller\my documents\visual studio 2005\projects\homework6\homework6.c 54 Error 14 error C2109: subscript requires array or pointer type c:\documents and settings\john miller\my documents\visual studio 2005\projects\homework6\homework6.c 55 Error 15 error C2109: subscript requires array or pointer type c:\documents and settings\john miller\my documents\visual studio 2005\projects\homework6\homework6.c 57 Error 16 error C2109: subscript requires array or pointer type c:\documents and settings\john miller\my documents\visual studio 2005\projects\homework6\homework6.c 60 Error 17 error C2109: subscript requires array or pointer type c:\documents and settings\john miller\my documents\visual studio 2005\projects\homework6\homework6.c 61 Error 18 error C2143: syntax error : missing ';' before 'type' c:\documents and settings\john miller\my documents\visual studio 2005\projects\homework6\homework6.c 68 Error 19 error C2065: 'entry' : undeclared identifier c:\documents and settings\john miller\my documents\visual studio 2005\projects\homework6\homework6.c 71 Warning 20 warning C4244: '=' : conversion from 'double' to 'float', possible loss of data c:\documents and settings\john miller\my documents\visual studio 2005\projects\homework6\homework6.c 80 Error 21 error C2224: left of '.clockNumber' must have struct/union type c:\documents and settings\john miller\my documents\visual studio 2005\projects\homework6\homework6.c 101 Error 22 error C2224: left of '.wage' must have struct/union type c:\documents and settings\john miller\my documents\visual studio 2005\projects\homework6\homework6.c 102 Error 23 error C2224: left of '.hoursWorked' must have struct/union type c:\documents and settings\john miller\my documents\visual studio 2005\projects\homework6\homework6.c 103


----- Original Message ----- From: "Marlon Brandão de Sousa" <splyt.lists@xxxxxxxxx>
To: <programmingblind@xxxxxxxxxxxxx>
Sent: Tuesday, October 30, 2007 5:59 PM
Subject: Re: one more try on C programming help


also post the "better fixed" code, it is the one you used to got ride
of these errors.
Marlon

2007/10/30, Marlon Brandão de Sousa <splyt.lists@xxxxxxxxx>:
You're getting it ... when you start to fix errors the compiler tells
you and learns to fix errors that the compiler didn't tell or tould
something uninteligable then it shows that you are being able to see
and fix for yourself what you did wrong before.
Marlon

2007/10/30, John Miller <n1umj@xxxxxxxxxxx>:
> OK, I got rid of 8 more errors, something stupid I was missing but the
> errors didn't say anything that led me right I just stumbled in to it. > The
> rest though I'm completely lost on.
> ----- Original Message -----
> From: "John Miller" <n1umj@xxxxxxxxxxx>
> To: <programmingblind@xxxxxxxxxxxxx>
> Sent: Tuesday, October 30, 2007 5:22 PM
> Subject: one more try on C programming help
>
>
> > OK, I've worked on this, changed it some and get nowhere. Yes, I did > > try
> > to compile it and out of 29 errors, I was able to make sense out of 1,
> > which fixed 4 of them but the rest are absolutely no good to me what > > so > > ever. I'm sick of looking at it, and for this week's assignment this > > has
> > to be 100%. I know if I stick with it alone, that will never happen so
if
> > Anyone can offer anything on this constructive I would really > > appreciate
> > it. I'm getting nowhere. If I see 1 more error telling me I'm missing
> > something that's actually there, there will be no more computer to do
this
> > on after I'm done with the hammer.
> >
> > (start code)
> > #include <stdio.h>
> >
> > /* function prototypes */
> >
> > void initData(emp, SIZE);
> >
> > float calculateOverTime(int entry, float *wagePtr,float
*hoursWorkedPtr);
> >
> > float calculateGrossPay(int entry, float *wagePtr,float
*hoursWorkedPtr);
> >
> > void displayEntry(int entry, int *clockNumberPtr,float *wagePtr,float
> > *hoursWorkedPtr);
> >
> >
> > struct emp;
> >
> > int main (char *argv, int argc)
> >
> > { /*get clock info*/
> >
> > int clockNumber; /*employee number*/
> >
> > float wage; /* declare wage */
> >
> > float hoursWorked; /*enter hours worked*/
> >
> > int i=0;//index for for loop
> >
> > initData(clockNumber,wage,hoursWorked);
> >
> > for (i=0;i<5;i++)
> >
> > getHoursWorked(i,clockNumber,hoursWorked);
> >
> > printf("Clock #\tWAge\thours\tOver time\tGross Pay\n");
> >
> > for (i=0;i<5;i++)
> >
> > displayEntry(i,clockNumber,wage,hoursWorked);
> >
> > struct emp myempArray[5];
> >
> > return(0);
> >
> > } /*end get clock info*/
> >
> > struct emp;
> >
> > void initData(int *clockNumberPtr,float *wagePtr,float > > *hoursWorkedPtr)
> >
> > { /* declaring clock numbers and wage*/
> >
> > int i; // index for for loop
> >
> > emp[0].clockNumber=98401; /*first employee*/
> >
> > emp[1].clockNumber=526488; /* second employee*/
> >
> > emp[2]clockNumber=765349; /*third employee */
> >
> > emp[3]clockNumber=34645; /*forth employee*/
> >
> > emp[4]clockNumber=127615; /*fifth employee */
> >
> > emp[0]wage=10.60; /* first employee wage
> >
> > emp[1]wage=9.75; /*second employee wage
> >
> > emp[2]wage=10.50; /* third employee wage */
> >
> > emp[3]wage=12.25; /*employee 4 wage */
> >
> > emp[4]wage=8.35; /* fifth employee wage 8/
> >
> > // init hours worked to 0
> >
> > for (i=0;i<5;i++)
> >
> > hoursWorkedPtr[i]=0;
> >
> > } /*end declaring clock and wage numbers*/
> >
> > void getHoursWorked(struct employee emp[])
> >
> > { /*prompt for hours*/
> >
> > printf ("Enter hours worked by %d: ",clockNumberPtr[entry]);
> >
> > scanf_s("%f", &(hoursWorkedPtr[entry]));
> >
> > } /*end prompt for hours*/
> >
> > float calculateOverTime(int entry, float *wagePtr,float > > *hoursWorkedPtr)
> >
> > { /* figure out overtime */
> >
> > float overTimeHours=hoursWorkedPtr[entry]-40;
> >
> > float overTimePay=0;
> >
> > if (overTimeHours>0)
> >
> > overTimePay=overTimeHours*(wagePtr[entry]*1.5);
> >
> > return (overTimePay);
> >
> > } /* end figuring out overtime */
> >
> >
> >
> > float calculateGrossPay(int entry, float *wagePtr,float > > *hoursWorkedPtr)
> >
> > { /* determine gross pay*/
> >
> > float grossPay=0;
> >
> > if (hoursWorkedPtr[entry]>40)
> >
> >
>
grossPay=(40*wagePtr[entry])+calculateOverTime(entry,wagePtr,hoursWorkedPtr);
> >
> > else
> >
> > grossPay=wagePtr[entry]*hoursWorkedPtr[entry];
> >
> > return (grossPay);
> >
> > } /*end determine gross pay */
> >
> > void displayEntry(int entry, int *clockNumberPtr,float *wagePtr,float
> > *hoursWorkedPtr)
> >
> > { /*desplay results */
> >
> > printf ("%d\t%0.2f\t%0.2f\t%0.2f\t%0.2f\n",
> >
> > emp.clockNumber,
> >
> > emp.wage,
> >
> > emp.hoursWorked,
> >
> > calculateOverTime(entry,wagePtr,hoursWorkedPtr),
> >
> > calculateGrossPay(entry,wagePtr,hoursWorkedPtr));
> >
> > } /* end desplay output*/
> >
> >
> >
> > (end code)
> >
> > __________
> > View the list's information and change your settings at
> > //www.freelists.org/list/programmingblind
> >
>
> __________
> View the list's information and change your settings at
> //www.freelists.org/list/programmingblind
>
>


--
When you say "I wrote a program that crashed Windows," people just
stare at you blankly and say "Hey, I got those with the system, for
free."
Linus Torvalds



--
When you say "I wrote a program that crashed Windows," people just
stare at you blankly and say "Hey, I got those with the system, for
free."
Linus Torvalds
__________
View the list's information and change your settings at
//www.freelists.org/list/programmingblind

__________
View the list's information and change your settings at //www.freelists.org/list/programmingblind

Other related posts: