This week's book giveaway is in the Reactive Progamming forum. We're giving away four copies of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams and have Adam Davis on-line! See this thread for details.
and a main method that ignores the overtime arg when called, that looks like this:
i usually dont like to post all my code, but in this case i feel its necessary.
I cant find out why the overtimeMultiplier is not read at all, its as if its not even there when called into action.
any ideas? suggestions?
the inputs are 10 for baseRate
60 for hours
and 2 for overtimeMultiplier
so the reason i hard coded a 1.5 is so that the overtime is payed at 1.5. but if the user decides to enter a multiplier then that multiplier should execute and multiply by 1.5 to increase the amount payed. Are you telling me that my method is wrong?? oh god no!!
rick pine wrote:even if i enter something less than 1.5 , it still runs
Please check If you have replaced hard coded argument 1.5 with local variable overtimeMultiplier while creating an object of WageCalculator in main method.
If inputs are
Base Rate: 10
Would you like to enter an overtime multiplier(yes/no)? yes
Overtime multiplier: 2
and you expect following as correct output
Base wage: 400.0
Overtime wage: 400.0
Total wage: 800.0
then you need to replace hard coded 1.5 with overtimeMultiplier in method overTimeWage() because although user enters 2 as Overtime multiplier It will calculate
( 1.5 * 10 ) * ( 60 - 40 ); resulting 300
If you want you can use conditional operator to reduce code lines in method baseWage() and overTimeWage().
You can override toString method of Object into WageCalculator class to display information so you just need to print reference variable n1 using print statement in main method like this System.out.println(n1); then you don't need write three separate print statements in main method.