• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

confusion.

 
ken zemaitis
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • 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.
 
Henry Wong
author
Marshal
Pie
Posts: 21518
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • 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
 
fred rosenberger
lowercase baba
Bartender
Posts: 12203
35
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
Marshal
Pie
Posts: 21518
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic