how to gain the overall total for this?


-Read two integers, representing a rate of pay (pence per hour) and a number of hours. Print out the total pay, with hours up to 40 being paid at basic rate, from 40 to 60 at rate-and-a-half, above 60 at double-rate. Print the pay as pounds to two decimal places.
-Terminate the loop when a zero rate is encountered. At the end of the loop, print out the total pay.
-The code for computing the pay from the rate and hours is to be written as a function.
-The recommended output format is something like:
Pay at RM30 /hr for 38 hours is RM1140
Pay at RM45 /hr for 48 hours is RM2160
Pay at RM60 / hr for 65 hours is RM3900
Total pay is RM7200


below is the code that i made.. but i m not sure how to get the total.
pls guide my mistake. im using borland 5.02





# include <stdio.h>
#include <conio.h>



int loop();
float rate();
float hour();

main ()
{
loop ();
getch();
return 0;

}
int loop()
{
int i=1;


while(i)
{
hour();
}
getch();
return 0;

}



float hour()
{

float a,c, rate();
{
printf ("\nKey in rate of pay: ");
scanf ("%f", &a);

printf ("\nKey in number of hours: ");
scanf ("%f", &c);

printf ("\nPay at RM%.2f /hr for %.2f hours is RM: %.2f", a,c,rate);
}

}



float rate()
{

float a,c,total;
{
if (c<=40)
{total=c*a ;
printf("%d",total);}
else if(c>=40 && c<=60)
{total=c*(a+a/2) ;
printf("%d",total); }
else if(c>=60)
{total=c*2*a ;
printf("%d",total);}
}

getch ();
return 0;
}
Please use [code] [ /code] boxes, so I can see your code in indented form. It will help us to help you.
Topic archived. No new replies allowed.