The First thing I did is -
Ran your code at IDEONE.com ,the online compiler , your solution throws the following Exceptions-
Exception in thread "main" java.util.InputMismatchException
at java.util.Scanner.throwFor(Scanner.java:840)
at java.util.Scanner.next(Scanner.java:1461)
at java.util.Scanner.nextInt(Scanner.java:2091)
at java.util.Scanner.nextInt(Scanner.java:2050)
at Main.main(Main.java:11)
So ,
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.
amm=i.nextInt();
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 amm=i.nextInt() with
amm=i.nextFloat();
So ,this will help you to Resolve the RunTime Error in your code. Check this Link
After resolving the runtime error [[ by just correcting a line that i mentioned above]] ,if you submit your solution ,you will get Wrong Answer
Wrong answer as there are several mistakes in your code -
(1)There is no need to check whether the input data is valid or not :
if(amm>2000 || amm<0)
System.exit(0);
Codechef is very strict .They will never provide a test data that doesnot satisfy the given constraint .
Refer the following FAQ
(2).You should not display
the input is [System.out.println(" Input\n............]
You should display the output in exactly the same way as mentioned in problem statement.
The printing of even additional whitespace results in wrong Answer.
(3).** Error(Logic/Strategical):**
Your logic is not correct.
(a)For successful transaction the sufficient and necessary condition is:
(Amount pooja want to draw %5==0) && (withdraw amount +.50(the bank service charge)) <= Balance amount.
But your code is not checking this codition.
Your solution allow pooja to make transaction even if (x%5) is not 0.
(b) If there is not enough money in the account to complete the transaction, just output the current bank balance.
You should not print :
"Insufficient Funds"
I will suggest you to read the problem statement once again and please must read all the FAQs ,several times