here is the code:
public class Main{
public static void main(String args[])
{
int n;
boolean fact=true;
while(fact)
{
n=Integer.parseInt(System.console().readLine());
if(n==42)
{
fact=false;
break;
}
System.out.println(n);
}}}