I ran your code at IDEONE.com, and your solution throws the following exception:
Exception in thread "main" java.util.InputMismatchException
obviously,you are getting a runtime error due to mismatch in input.
Just Read the problem statement again especially the Input format section :
*First Input:Positive integer 0 < X <= 2000 - the amount of cash which Pooja wishes to withdraw.
Second Input:Nonnegative number 0<= Y <= 2000 with two digits of precision - Pooja’s initial account balance.*
So ,the second input must be a floating point number.
But your code takes the second input as an Integer.
balance=sc.nextInt();//Instead of float ,you are taking integer Input :(
So,this is where the Mismatch occur and yes,that’s the reason ,you are getting a Runtime Error.
How to Recover?
Just Replace(Correct) the line balance=nextInt() with
The rest of the things are absolutely Fine .