Re: a little C programming help I hope

  • From: "John Miller" <n1umj@xxxxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Wed, 17 Oct 2007 16:35:03 -0400

That's what I was trying for, but I guess from another email I was about 95% out to lunch on this one. I guess we'll see what happens, but I don't think I have time to figure it out right and get it done in time. ----- Original Message ----- From: "Jackie McBride" <abletec@xxxxxxxxx>

To: <programmingblind@xxxxxxxxxxxxx>
Sent: Wednesday, October 17, 2007 3:38 PM
Subject: Re: a little C programming help I hope


John:

Consider making more functions.  The only thing in the main function,
really, should be calls to other functions, e.g., the main function
consolidates the program calls to its functions.  I would arrange it,
for example, such that 1 function gets input, the other function
returns the pay, & a last prints the output.

Thus, my main function would look like:
getInput
PayCalc
PrintOutput

That's not written in stone, but a function should perform a single
task, & if u consider each of those as a single task, then u kind of
have an easy way of dividing your program into modules.

On 10/17/07, John Miller <n1umj@xxxxxxxxxxx> wrote:
Hi hope this is just a little help this time. I've been working on this long
enough this morning, and last night and before I finish and find out I
screwed up royally, I'm wondering if some one can look this over and let me know how I've done so far, what I might want to do different and since I am
getting stuck a little, maybe a little advice on how to do the rest of it
though, if I am very close, or good here I think I know where I'm going with the rest of it. this is just what I get from the class notes and I'm getting to the point where I'm not comfortable with what I am doing though I'm about
90% sure I started off right.
Thanks,

(begin code)

#include <stdio.h>

int main (void)

{

int clock[5];

/* clock number */

float gross[5];

/* gross pay */

float hours[5];

/* hours worked */

float overtime;

float wage[5];

/* hourly wage */

int i;

/* Prompt for employee information */

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

{ /*begin for loop*/

#include float GetClockedHours ( unsigned long int ClockNumber )

{ /* begin clocked hours function */

float ClockedHours;

printf ( "Enter hours worked for clock %6lu: ", ClockNumber );

return ( clocked hours );

}


printf("Enter number of hours worked: ");

scanf_s("%f", &hours[i]);

void calc_gross_pay1 (float wage[], float hours[], float ot_pay[],

float gross_pay[], int emp_count)

{ int i; /* array index */

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

{

/* test to see any overtime was worked */

if (hours[i]> 40)

/* calculate gross pay */

gross_pay[i] = 40 * wage[i] + ot_pay[i];

else gross_pay[i] = wage[i] * hours[i];

}



GrosslyPaid[5]; /* gross pay array */ unsigned int NumberOfEntries = 5; /*
number of entries */ float OvertimeHours[5]; /* overtime hrs array */ /*
wage rates array */ float WageRate[5] = { 10.60, 9.75, 10.50, 12.25, 8.35 };
/* Prompt for input values from the screen */ /* calculate overtime hours
and gross pay */ for ( EntryNumber = 0; EntryNumber < NumberOfEntries;
EntryNumber++ ) { ClockedHours[EntryNumber] = GetClockedHours (
ClockNumber[EntryNumber] ); OvertimeHours[EntryNumber] = CalcOvertimeHours
( ClockedHours[EntryNumber] );

GrosslyPaid[EntryNumber] = CalcGrossPay ( ClockedHours[EntryNumber],
OvertimeHours[EntryNumber], WageRate[EntryNumber] );

}

} /*end first for*/

/* calculate gross pay */

/* print out employee information to the screen */

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

{ /*start printf loop*/

printf ("\t----------------------------------------------------------\n");

printf ("\tClock#        Wage        Hours        Gross\n");

printf ("\t----------------------------------------------------------\n");

printf ("\t%06i %5.2f %5.1f %7.2f\n",clock[i],wage[i],hours[i],gross[i]);
printf("This employee worked %f hours with a per-hour basis of %f.\n",
hours[i], wage[i]);

printf(" gross pay is %f.\n", gross[i]);

} /* end printf loop*/


return 0;

}

(end code)







John Miller N1UMJ
AIM and yahoo messenger: N1UMJ Skype: n1umjjohn
home page:
http://home.comcast.net/~n1umj/wsb/html/view.cgi-home.html-.html
myspace: http://www.myspace.com/n1umj

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




--
Jackie McBride
Please sign the Yahoo Accessibility petition at:
<http://www.petitiononline.com/yabvipma/petition.html>
& Check out my homepage at:
www.abletec.serverheaven.net
__________
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: