Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

payroll

 
Jossy Johnson Um
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
[Thumbnail for payroll.png]
 
Mohamed Sanaulla
Saloon Keeper
Posts: 3159
33
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Saloon Keeper
Posts: 3159
33
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So have you resolved the issue?
 
Jossy Johnson Um
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you help? I have not resolved the problem.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic