0
Can someone help me with java swtich statement.
So I need this to convert from if else to switch statement, but I can't figure it out. Please help, just point out where should I start. Tia. Btw, sorry for my code, it's messy 😅 https://code.sololearn.com/cl2dSlnI3G3A/?ref=app
1 Resposta
+ 1
First of all modify the datatype of hours to int.
Secondly, add a initial value for rate.
Then you need a new variable to save the SIGN of the result hours - 40.
You can do something like :
int signum = Long.signum((long) hours-40 );
switch(signum) {
case -1:
break;
case 0:
break;
case 1: othours = hours - minhours;
otpay = othours * otrate;
break;
}
I hope it helps