printf ("enter an employee id number, -1111 to end");
scanf ("%d", &id);
while (id != -1111)
{
printf ("enter the amount of hours worked");
scanf ("%f", &hours);
/*
** Test to see if the new hour count is less than the minimum
** seen so far. If it is, then replace minh with the new value.
*/
/* Your code goes here, you lazy sack of cat vomit. */
/*
** Test to see if the new hour count is more than the maximum
** seen so far. If it is, then replace maxh with the new value.
*/
/* Your code goes here, you lazy sack of cat vomit. */
if (hours <= 40)
wages = hours * 10;
else
wages = 40 * 10 + (hours - 40) * 15;
sum += wages;
count++;
printf ("enter another employee,-1111 to end");
scanf ("%d", &id);
}
avg = sum / count;
printf ("The total number of employees paid is %.0f.\n", count);
printf ("The average salary per week is $%.2f.\n", avg);
printf ("The maximum salary per week is $%.2f.\n", maxh);
printf ("The minimum salary per week is $%.2f.\n", minh);
return 0;
}
--
C-FAQ: http://www.eskimo.com/~scs/C-faq/top.html
"The C-FAQ Book" ISBN 0-201-84519-9
C.A.P. Newsgroup http://www.dejanews.com/~c_a_p
C.A.P. FAQ: ftp://38.168.214.175/pub/Chess%20Analysis%20Project%20FAQ.htm
I don't know if what I want exists but I would
just like someone to add code to this program that
would give maximum and minimum values of the salary.
Greg Martin: you've been great and I will save your
solution but right now it's a little above me.
Also I know that void main(void) may not be appropriate
so do not make comments about that please and I'm sorry
if it makes some of you uncomfortable but please ignore it
for now, I'll change later!!!
Thanx in advance
Alan
#include<stdio.h>
void main( void )
{
int id;
float sum=0,wages,avg,max=0,min,hours,count=0;
printf("enter an employee id number, -1111 to end");
scanf("%d",&id);
while (id!=-1111)
{
printf("enter the amount of hours worked");
scanf("%f",&hours);
if (hours<=40)
wages=hours*10;
else
wages=40*10+(hours-40)*15;
sum=sum+wages;
count++;
printf("enter another employee,-1111 to end",id);
scanf("%d",&id);
}
avg=sum/count;
printf("The total number of employees paid is %0.0f.\n",count);
printf("The average salary per week is $%3.2f.\n",avg);
printf("The maximum salary per week is $%3.2f.\n",max);
printf("The minimum salary per week is $%3.2f.\n",min);
}
Change it now, why do things incorrectly when you know the correct way
of doing it??
>
> Thanx in advance
> Alan
>
> #include<stdio.h>
> void main( void )
int
main(void)
> {
>
> int id;
> float sum=0,wages,avg,max=0,min,hours,count=0;
float sum,wages,avg,max,min,hours,count;
sum = wages = avg = max = min = hours = count = 0.0;
> printf("enter an employee id number, -1111 to end");
> scanf("%d",&id);
>
> while (id!=-1111)
> {
> printf("enter the amount of hours worked");
> scanf("%f",&hours);
>
> if (hours<=40)
> wages=hours*10;
> else
> wages=40*10+(hours-40)*15;
>
if ( min > wages )
min = wages;
if ( max < wages )
max = wages;
> sum=sum+wages;
> count++;
>
>
>
> printf("enter another employee,-1111 to end",id);
> scanf("%d",&id);
> }
> avg=sum/count;
> printf("The total number of employees paid is %0.0f.\n",count);
> printf("The average salary per week is $%3.2f.\n",avg);
> printf("The maximum salary per week is $%3.2f.\n",max);
> printf("The minimum salary per week is $%3.2f.\n",min);
> }
--
---------------------------------------
Rick Dearman - ri...@ricken.demon.co.uk
---------------------------------------
I can't stand cheap people. It makes me real mad when someone says
something like, ``Hey, when are you going to pay me that $100 you owe
me?'' or ``Do you have that $50 you borrowed?'' Man, quit being so
cheap!
-- "Deep thoughts by Jack Handey"