life,the universe and everything

import java.io.*;
public class work
{
public static void main(String args[])throws IOException
{
BufferedReader br=new BufferedReader(new InputStremReader(System.in));
int n;
while((n=Integer.parseInt(br.readLine()))!=42)
{
System.out.println(n);
}
}
}

some one plese point out the mistakes i have made and explain them please.

Spelling mistake. Write InputStreamReader instead of InputStremReader.

These are the errors:

  1. You can not declare the class public. Either remove the public or change the class name to Main.
    Either class work or public class Main.

The reason is that Codechef tests the code by putting the code in a file named Main.java

In Java, the name of the file should be the same as the public class.

So if the class is public, it has to be named as Main.

The second solution is don’t use a public class. In this case you can use any class name.

2. You have spelled InputStreamReader wrongly.

Here is the corrected solution link: http://www.codechef.com/viewsolution/4375839

1 Like
//