java - Why is this showing wrong answer on codechef, its working on my ide -


pooja withdraw x $us atm. cash machine accept transaction if x multiple of 5, , pooja's account balance has enough cash perform withdrawal transaction (including bank charges). each successful withdrawal bank charges 0.50 $us.

calculate pooja's account balance after attempted transaction .

input

positive integer 0 < x <= 2000 - amount of cash pooja wishes withdraw.

nonnegative number 0<= y <= 2000 2 digits of precision - pooja's initial account balance.

output

output account balance after attempted transaction, given number 2 digits of precision. if there not enough money in account complete transaction, output current bank balance.

import java.util.scanner;   class hs08test {     public static void main(string[] args) {         scanner s =new scanner(system.in);         double x = s.nextdouble();         double y =s.nextdouble();         if( x>=0.00 && x<=2000.00 &&y>=0.00 && y<=2000.00){             if(x==0){                 system.out.printf("%.2f",y);              }             else if(x%5==0.00 && x<=y){                 system.out.printf("%.2f",y-x-0.50);             }             else{                 system.out.printf("%.2f",y);             }         }     }  } 

the code works fine on ide, showing wrong answer on codechef. showing "wrong answer" when compiling on codechef.i not getting real issue. please me out on this.

the problem statement says "has enough cash perform withdrawal transaction (including bank charges)", bank charge ignored in test.

the program allows balance go negative x=5, y=5.07.

in addition, not use double short decimal fractions need calculated exactly. see is floating point math broken?


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -