I am in the second semester of computer programming and am not so familiar with functions. Arrays I know but don't know how to use them in functions either.
I am looking for someone who can help me with the following:
The problem is as follows:
Read two numbers, representing a rate of pay ($ per hour) and a number of hours. Print out the total pay, with hours up to 40 being paid at a basic rate, from 40 to 60 at a rate-and-a-half, above 60 at double-rate. Print the pay as $ to 2 decimal places.
Terminate the loop when a zero rate is encountered. At the end of the loop, print out total pay.
The code for computing the pay from the rate and hours is to be written as a function.
A loop , arrays and at least two functions should be used.
One function for calculation and another for printing the total pay.
The output format should look something like this:
Pay at $2.10 / hr for 12 hours is $25.20
Pay at $2.20 /hr for 48 hours is $114.40
Pay at $2.40 / hr for 68 hours is $206.40
Pay at $2.60 / hr for 48 hours is $135.20
Pay at $2.80 / hr for 68 hours is $240.80
Pay at $3.00 / hr for 48 hours is $156.00
Total Pay is 928.80
I've tried to write the program without arrays, and it kind of works , but don't know how to use arrays and functions at the same time
This is how I started:
Double pay_calc(double, double rate);
double num1, num2;
printf("please enter hours for employee:",j+1);
printf("\nplease enter rate for employee:"j+1);
if (num1[j]<0 || num2[j]<0)
printf("\nplease enter a positive value!!!");
Double pay_calc(double hour, double)
double j=0, pay_calc;
printf("\n\n Pay at %.2lf for %.2lf hours is %.2lf", rate[j],hour[j], pay_calc[j]);
Now I need another function that prints the total pay, how do I terminate the loop when a zero is entered?
PLEASE HELP ! ! ! Your urgent assistancewill be highly appreciated.