This discussion is archived
7 Replies Latest reply: Jan 12, 2013 5:14 AM by 982162 RSS

Simple java program that has a few errors

982162 Newbie
Currently Being Moderated
Greetings to everone

I was fiddling around with some pseudocode and thought of using it with java, see following code and error , it basically finds whether the number inputted is even.
import java.util.*;

       public class modulo

      Scanner readone = new Scanner(;
      int num1;
      System.out.println("Please enter a number:   ");
      num1 = readone.nextInt();
      public static void main(String [] moD)

        int num2 = num1 %2;
             if(num2 ==0)
               System.out.println("The inputted number is even");


Below are the errors i get, what i have in mind is that the variables and scanner should be declared within the void main, please correct me if i'm worng guyz <identifier> expected
System.out.println("Please enter a number: ");
^ illegal start of type
System.out.println("Please enter a number: ");
^ <identifier> expected
num1 = readone.nextInt();
3 errors

Yours sincerely



  • Correct Answers - 10 points
  • Helpful Answers - 5 points