why this java code is showing a runtime error.

atm
code
for
java

#1

import java.util.Scanner;
public class ATM{
public static void main(String[] args){
Scanner ip = new Scanner(System.in);
double bal = ip.nextDouble();
int amt = ip.nextInt();
if((bal>=0&&bal<=2000)&&(amt>0&&amt<=2000)){
if((bal>amt+0.5)&&(amt%5==0)){
bal-=(amt+0.5);
System.out.println(bal);}
else System.out.println(bal);
}
}
}

RESULT : RUNTIME ERROR
Doubt ; Y is it so? it is working on pc


#2

The name of the class should be Main in java for all the submissions on CodeChef. Rename it to Main. Please don’t try different programming languages if it’s not getting accepted in one language. Try debugging the error to check for mistakes.


#3

You are taking the inputs in reverse order. You need to input amt first and then bal. You need not make the class public.


#4

Its not any compulsion of having class name as Main on Codechef.


#5

@vinayawsm…if u declare the class as public…then it is a compulsion!!!


#6

okey. I am sorry I didn’t know that.