• Post Reply Bookmark Topic Watch Topic
  • New Topic
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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Bear Bibeault
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • salvin francis
  • Stephan van Hulst
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Jj Roberts

payroll

 
Greenhorn
Posts: 16
  • 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]
 
Bartender
Posts: 3225
34
IntelliJ IDE Oracle Spring Chrome Java
  • 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: 16
  • 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
Bartender
Posts: 3225
34
IntelliJ IDE Oracle Spring Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So have you resolved the issue?
 
Jossy Johnson Um
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you help? I have not resolved the problem.
 
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
 
You totally ruined the moon. You're gonna hafta pay for that you know. This tiny ad agrees:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic