programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
• Campbell Ritchie
• Ron McLeod
• Tim Cooke
• Liutauras Vilda
• Jeanne Boyarsky
Sheriffs:
• Paul Clapham
• Rob Spoor
• Junilu Lacar
Saloon Keepers:
• Stephan van Hulst
• Tim Holloway
• Piet Souris
• Carey Brown
Bartenders:

# payroll

Greenhorn
Posts: 16
• Number of slices to send:
Optional 'thank-you' note:

I have a simple code for payroll. I believe there is a logical error.
When the hourWorked is > 40hrs respecting any payRate I do get a wrong answer.
Look at my attachment for the result giving for 41 hours at 40 dollars per hour payRate.
= 1700 as opposed to 1660. So basically my program is not executing the else if when the
hourWorked is > than 40 hours. I will be glad if someone can help me on this.

One more thing, I will like to have a number of users go into the payroll system and
use the data type for their gross pay. I.E to repeat the process for different employees. I will
also be happy to know how to do it in such way say a specific number of worker can get a grosspay.
Thereafer, the program will stop with ''Goodbye name exiting payroll system now".
or
Now I need to build on it like keep similar data for employees and have the gross pay displayed until there is no more employee data to process. Then I will display "Good Bye."
payroll.png

Bartender
Posts: 3225
34
• Number of slices to send:
Optional 'thank-you' note:
I am not sure if your calculation is right. Let me trace the program for you:
payRate = 40
hoursWorked = 41
grossPay = hoursWorked * payRate = 1640

as hoursWorked is greater than 40:
grossPay += ((hoursWorked-40) * ((payRate*3)/2)) => grossPay = 1640 + ((41-40) * ((40*3)/2)) => grossPay = 1700.

So the result is grossPay = 1700.

Jossy Johnson Um
Greenhorn
Posts: 16
• Number of slices to send:
Optional 'thank-you' note:
That is so wrong and it frustrated me. In any case I kept trying.

after few changes the if else doesn't execute I get ..... hoursWorked with OT as 40 and the grosspay as 0.0 dolars. Thanks.

Mohamed Sanaulla
Bartender
Posts: 3225
34
• Number of slices to send:
Optional 'thank-you' note:
So have you resolved the issue?

Jossy Johnson Um
Greenhorn
Posts: 16
• Number of slices to send:
Optional 'thank-you' note:
Can you help? I have not resolved the problem.

Ranch Hand
Posts: 4632
• Number of slices to send:
Optional 'thank-you' note:
you need some debugging statements to find out what's going on

add the indicated lines, then try to work out why it prints out what it does

and you can do the same for grosspay