I am trying to answer the following question. Tested on my IDE and it is compiling fine but on the site, it throws following error:
runtime error (NZEC) edit ideone it
Please advice what am doing wrong.
Question rewrite small numbers from input to output. Stop processing input after reading in the number 42. All numbers at input are integers of one or two digits.
Answer
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
int i = 0;
while (i != 42){
Scanner s = new Scanner(System.in);
i = s.nextInt();
System.out.println(i);
}
}
}