title: How can I create a method that evaluates two variables from main class?
body: <p>I have to create a program in which the user has to guess a number from 1 to 10, teacher asked us to create 6 methods: one to generate random numbers, other to check that the answer the user gives and the random number are the same, etc) I'm doing the method in which the input and random number has to be the same but I'm not sure I'm doing it correctly:</p>
  <pre><code>public class Guessgame {   
      static int a;
      static int a1;
      static int a2;
      static int b;
  
      public static void main(String[] args) {
          Scanner input = new Scanner (System.in); // User input
  
          b = generator(); //declara el numero aleatorio generado en &quot;generator()&quot;
  
          System.out.println(&quot;Welcome to a game, you have to guess a number between 1 to 10&quot;);
          System.out.println(&quot;You have three tries&quot;);
  
          System.out.println(b);
  
          System.out.println(&quot;What is your first guess?&quot;);
  
          a = input.nextInt(); //declara el numero que declaro el usuario
  
          evaluator();   
                                   
      }
  </code></pre>
  <p>And here's the evaluator method:</p>
  <pre><code>        public static void evaluator(){
          if ( a == b ){
              System.out.println(&quot;Good&quot;);                
          }
          else{
              System.out.println(&quot;Bad&quot;);
          }
      }
  </code></pre>
  <p>I just had to change evaluator(); to evaluator(a, b);</p>