# Computing Salary

September 26, 2010 at 01:09:57
Specs: Windows XP
 Anyone can help me about my problem!im new in using turbo c.and i want to create a program that compute the weekly salary of the employee.here my sample code:#include#includechar Tin[20],Tout[20],hourIn[20],minIn[20],hourOut[20],minOut[20]; int Hrs,late,under,numHourIn,numMinIn,numHourOut,numMinOut,totalHrs;main () { printf("Enter Time-In:"); scanf("%d%s",&hourIn,&minIn); printf("Enter Time-Out:"); scanf("%d%s",&hourOut,&minOut); Hrs=0; late=0; under=0; /* hourIn= copy(Tin,1,2); minIn= copy(Tin,4,5); hourOut= copy(Tout,1,2); minOut= copy(Tout,4,5); */ /*val(hourIn,numHourIn,err); val(minIn,numMinIn,err); val(hourOut,numHourOut,err); val(minOut,numMinOut,err);*/ numHourIn = numHourIn + (numMinIn/60); numHourOut = numHourOut + (numMinOut/60); if (numHourIn==0 && numHourOut==0) Hrs=0; else { if (numHourIn <=8) numHourIn=8; if (numHourOut >=17) numHourOut=17; if (numHourIn>=8 ||numHourOut <=17) { if (numHourIn>=12 && numHourIn<=13) numHourIn= 13; if (numHourOut>=12 && numHourOut<=13) numHourOut= 13; if (numHourOut > 12) if (numHourIn > 12) Hrs= (numHourOut - numHourIn); else Hrs= (numHourOut - numHourIn) -1; else Hrs= numHourOut - numHourIn; } } printf("%s%s",totalHrs + Hrs); getch(); }My question is,how to compute the total salary:by the way the time format is military time;these the scenario;if the employee have time in at 08:00 and time out 17:01 he have a total of 8 hours.my problem is i cannot display the total hours and the total salary.please help!

See More: Computing Salary

#1
September 27, 2010 at 17:58:52
 If you're doing weekly pay, then you might consider using an array to hold each day's hours worked. Depending on your need, you'd probably want to convert the mins to a fraction; for example: 0-14 mins = 0; 15-29 mins = 0.25; 30-44 mins = 0.5; 45-59 mins = 0.75. Once you've got the hours, add the fraction. Lastly, multiply it by the hourly wage.For the 24 hour clock, something like below may do```num_hrs = hour_out < hour_in ? ((24 - hour_in) + hour_out) : hour_out - hour_in; num_mns = min_out < min_in ? min_in - min_out : min_out - min_in; ``` To start with, you might want to try direct assignment on hour_in, min_in, hour_out, and min_out just to see if you get the expected answer; if you do, proceed with user input. HTH-------------------------------------------I have no aspiration for preaching. ;-)

Report •

#2
September 28, 2010 at 19:44:49
 tnx for the reply!i will try it!god bless

Report •

#3
December 9, 2010 at 19:51:04
 create a program that will compute for the total salary, total deduction and net pay for the total salary consider the rate per hour is 48.50 for deduction i: SSS Pag-ibig philhealth for the tax 10% of the salary

Report •

Related Solutions