• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

confusion.

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello.
im still very new to the java language.
im having a dilemma building a program that is supposed to calculate pay.
employees are supposed to make 5.15 an hour until they work more than 40.
once they work more than 40 they are supposed to make time and a half.
i am also supposed to increment the number of calculations i make for another feature of the program.
and finally, im trying to keep track of the total amount of pay that has been calculated.
any assistance will be greatly appreciated.
i have tried coding this many different ways.
this is what i have come up with as of right now.

if (choice == pay) {
System.out.print("Hours Worked: ");
double hours = Utility.readDouble();
double payroll = (5.15 * hours);
System.out.println("Gross Pay: " + payroll);
if (pay == 0)
break;
{
if (pay > 0);
System.out.println("Invalid Hours Worked.");
continue;
}

Utility.pressEnter();
System.out.println("");

}
//Statistics!!!

else if (choice == stats) {
System.out.print("Payroll Calculations Performed: ");
Utility.pressEnter();
System.out.println("");
}


thank you.
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay, I have no idea what "choice", "pay", or "stats" do... so I can't comment on it. However, the problem is here.



The pay is not just 5.15 time hours. That is true only for the first 40 hours. The formula has to be adjusted to account for that.

Henry
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Kenny,

what you've posted is not a complete java program. I don't know if you omitted it just to get to the meat and bones, or if you don't know how to write a complete program.

I'm not critisizing, i'm just trying to understand where your difficulties lie.

So, does what you have compile? does everything else work but this part? if this is the only thing that doesn't work, what are you expecting it to do vs. what DOES it do?

answering these questions will help others help you.

also, when you post code, please use the code tags around your source. this will preserve the spacing and make it easier to read.
 
ken zemaitis
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by fred rosenberger:
Kenny,

what you've posted is not a complete java program. I don't know if you omitted it just to get to the meat and bones, or if you don't know how to write a complete program.

I'm not critisizing, i'm just trying to understand where your difficulties lie.

So, does what you have compile? does everything else work but this part? if this is the only thing that doesn't work, what are you expecting it to do vs. what DOES it do?

answering these questions will help others help you.

also, when you post code, please use the code tags around your source. this will preserve the spacing and make it easier to read.




ah, yes, this is not the entire program.
there is a switch before this code.
determining which function to perform.
whether its the payroll calculator, or the statistics portion.
the program i have compiles.
i am just having trouble with the mathmatic codes.
ie the payroll, and adding up all of the payrolls.
right now the program only compiles, and im just having trouble putting the right code in the right places.
anyway.
im still new here, so im still trying to pick up on things.
thanks for the advice.
its very much appreciated.
 
ken zemaitis
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Henry Wong:
Okay, I have no idea what "choice", "pay", or "stats" do... so I can't comment on it. However, the problem is here.



The pay is not just 5.15 time hours. That is true only for the first 40 hours. The formula has to be adjusted to account for that.

Henry




choice, pay and stats are just names for the different sections of the code.
choice is what determines what section of the program to run.
the sections include pay and stats.

and as far as the payroll portion goes, im having trouble trying to put together a code that acknowledges that a number larger than 40 has been entered.

thanks a lot for your help.
 
Henry Wong
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

and as far as the payroll portion goes, im having trouble trying to put together a code that acknowledges that a number larger than 40 has been entered.



How about...


if ( hours > 40.0 ) {
// Acknowledge that a number larger than 40 has been entered.
} else {
// Nack
}



Henry
 
reply
    Bookmark Topic Watch Topic
  • New Topic