title: Java error message "Cannot be resolved to a variable"?
body: <p>ok so I'm kinda new to java and I'm trying to make a class which will be able to ask the user to input a 12 digit long upc code, check to make sure its a valid code, and then display if it is or not. I've got quite a few errors with the current program that I have and I can't seem to figure it out. This is the code that I have so far: </p>
  
  <pre><code>public class Upc {
      private long upc;
  
      public Upc(long upcs) {
          upc = upcs;
      }
  
      public long getUpc() {
  
          int m = (n2 + n4 + n6 + n8 + n10);
          long n = (n1 + n3 + n5 + n7 + n9 + n11);
          long r = (10 - (m + 3 * n) % 10);
  
          long n12 = (int) (upc % 10);
          upc /= 10;
          long n11 = (int) (upc % 10);
          upc /= 10;
          long n10 = (int) (upc % 10);
          upc /= 10;
          long n9 = (int) (upc % 10);
          upc /= 10;
          long n8 = (int) (upc % 10);
          upc /= 10;
          long n7 = (int) (upc % 10);
          upc /= 10;
          long n6 = (int) (upc % 10);
          upc /= 10;
          long n5 = (int) (upc % 10);
          upc /= 10;
          long n4 = (int) (upc % 10);
          upc /= 10;
          long n3 = (int) (upc % 10);
          upc /= 10;
          long n2 = (int) (upc % 10);
          upc /= 10;
          long n1 = (int) (upc % 10);
  
          if (r == n12) {
              return (upc + " is a feasible UPC code");
          } else {
              return (upc + " is an invalid UPC code");
          }
      }
  }
  </code></pre>
  
  <p>and my errors are as follows:</p>
  
  <pre><code>13 errors found:
  File: C:\Users\Andrew\Downloads\Upc.java  [line: 10]
  Error: n2 cannot be resolved to a variable
  File: C:\Users\Andrew\Downloads\Upc.java  [line: 10]
  Error: n4 cannot be resolved to a variable
  File: C:\Users\Andrew\Downloads\Upc.java  [line: 10]
  Error: n6 cannot be resolved to a variable
  File: C:\Users\Andrew\Downloads\Upc.java  [line: 10]
  Error: n8 cannot be resolved to a variable
  File: C:\Users\Andrew\Downloads\Upc.java  [line: 10]
  Error: n10 cannot be resolved to a variable
  File: C:\Users\Andrew\Downloads\Upc.java  [line: 11]
  Error: n1 cannot be resolved to a variable
  File: C:\Users\Andrew\Downloads\Upc.java  [line: 11]
  Error: n3 cannot be resolved to a variable
  File: C:\Users\Andrew\Downloads\Upc.java  [line: 11]
  Error: n5 cannot be resolved to a variable
  File: C:\Users\Andrew\Downloads\Upc.java  [line: 11]
  Error: n7 cannot be resolved to a variable
  File: C:\Users\Andrew\Downloads\Upc.java  [line: 11]
  Error: n9 cannot be resolved to a variable
  File: C:\Users\Andrew\Downloads\Upc.java  [line: 11]
  Error: n11 cannot be resolved to a variable
  File: C:\Users\Andrew\Downloads\Upc.java  [line: 39]
  Error: Type mismatch: cannot convert from java.lang.String to long
  File: C:\Users\Andrew\Downloads\Upc.java  [line: 42]
  Error: Type mismatch: cannot convert from java.lang.String to long
  </code></pre>
  
  <p>I feel like fixing one or two things will eliminate alot of this, can anyone help me?</p>