code link:
please check
Problem in simple input challenge
Your code is correct, just create the scanner object outside the while loop because it only needs to be created once. So put this statement :
Scanner scn=new Scanner(System.in);
outside your while loop.