Я получаю 'RunTime Error' java.util.NoSuchElementException в строке, где я пытался получить пользовательский ввод.Не знаю, как от него избавиться.
public static void main (String[] args)
{
Scanner sc = new Scanner(System.in);
int input = sc.nextInt();
double amount = sc.nextDouble();
if(input%5!=0){
System.out.println(String.format("%.2f", amount));
}else if(input>amount){
System.out.println(String.format("%.2f", amount));
}else{
double bankAmount = 0.50;
double ans = amount - (double)input;
System.out.println(String.format("%.2f",ans-bankAmount));
}
sc.close();
}
Полная ошибка:
Exception in thread "main" java.util.NoSuchElementException
at java.util.Scanner.throwFor(Scanner.java:862)
at java.util.Scanner.next(Scanner.java:1485)
at java.util.Scanner.nextInt(Scanner.java:2117)
at java.util.Scanner.nextInt(Scanner.java:2076)
at Codechef.main(Main.java:14)