Run Time Error

Hello to everyone,

I’m trying to submit the solution of ATM problem but i’ve got some runtime error that i can’t solve someone could help me?

 import java.util.*;

 class Atm
  public static void main (String[] args) 
    double endAccountBalance;
    double taxes = 0.50;
	Scanner sc=new Scanner(;

        int amount = sc.nextInt();
        double balance=sc.nextDouble();
        if(balance < 2000)
           if(amount%5==0 && (amount+taxes)<balance)
            endAccountBalance = balance-amount-taxes;


Above is my code…

This is the error:

           Exception in thread "main" java.util.NoSuchElementException
          at java.util.Scanner.throwFor(
          at java.util.Scanner.nextInt(
          at java.util.Scanner.nextInt(
           	at Atm.main(

Many thanks for your support!


Worked fine when I ran your code in Eclipse IDE , Only thing I changed was I added public as class modifier in ATM class.
public class Atm{…}
Hope this helps :smiley:

I continue to have the same problem on the IDE of CodeChef…I can’t understand the error …

Did you provide required input in custom input?

1 Like

The IDE say that is not possible to compile the code…

I dont know mate i changed it back by removing public , your original code that is ran , on JAVA(HotSpot 8u112) on codechef compiler and it was executed normally , Inputs i gave were 800 1000.
Please try again it works.