title: declaring data type of a variable in java
body: <p>So I am in an intro class to Java. I'm trying to write my first program. It's a simple program that asks for a number(X) which equals the number of rounds to be completed. Next you run a while loop that adds the total score until X number of rounds have been completed. The textbook doesnt really answer my question. I'm declaring 3 integers. Do I declare these in the main method, or inside the while loop. We have not started using a Java editor yet, so i'm not sure how to check this. He wants us to write out the code, but i'm not sure where to declare these integers, and how its supposed to be properly written. Any help would be great, thanks! </p>
  
  <pre><code>public class Question2
  {
      public static void main (String [] args )
      {
          Keyboard kbd;
          Kbd = new keyboard();
          int n, tot, x;
          System.out.println( “How many?”);
          x = kbd.readInt();
      }
      while ( n &lt; x )
      {
          System.out.println( “Enter a score”);
          s = kbd.readInt();
          tot = (tot + s);
          n = (n + 1);
      }
  }
  </code></pre>