aspose file tools*
The moose likes Beginning Java and the fly likes confusion. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "confusion." Watch "confusion." New topic
Author

confusion.

ken zemaitis
Ranch Hand

Joined: Sep 26, 2005
Posts: 42
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
Sheriff

Joined: Sep 28, 2004
Posts: 18747
    
  40

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


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11246
    
  16

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.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
ken zemaitis
Ranch Hand

Joined: Sep 26, 2005
Posts: 42
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

Joined: Sep 26, 2005
Posts: 42
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
Sheriff

Joined: Sep 28, 2004
Posts: 18747
    
  40

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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: confusion.