title: String method in Java: charAt()
body: <p>I have an assignment that I'm finding a bit difficult. We're reading an external file to get the numbers needed for the program, which is not a problem. Here is the prompt: </p>
  
  <p>To check the validity of the code you need to analyze each digit in the code including the check digit. Assume that the first digit is in position zero, add the digits in the even positions and multiply the result by 3.  Add this to the sum of the odd positioned digits.  Only if the total is a multiple of 10 is the UPC number valid. Write a program that reads a UPC code (as a string) from an external file, analyze the code, and output the code and a label “Invalid” or “Valid”. </p>
  
  <p>Sample Output: UPC Code:</p>
  
  <p>016499215511    Valid</p>
  
  <p>372415613274  Invalid</p>
  
  <p>155512994610    Valid</p>
  
  <p>011165459192  Invalid</p>
  
  <p>838241762110  Invalid</p>
  
  <p>Here is what I have in my code so far: </p>
  
  <pre><code>import java.io.*;
  import java.util.*;
  public class Prog700d
  {
      public static void main(String[] args) throws IOException
      {
          Scanner kbReader = new Scanner(new File("C:\\Users\\Guest\\Documents\\java programs\\Prog700d\\Prog700d.in"));
          while(kbReader.hasNextLine())
          {
              String upc = kbReader.nextLine();
              int length = upc.length();
              int a = upc.charAt(0);
              System.out.println(a);
  </code></pre>
  
  <p>My main issue is with the charAt(). I think that if I use charAt(), then I will get the character at the given index. So I decided to test this by using charAt(0), and I ended up getting these numbers:</p>
  
  <p>49
  55
  53
  49
  51</p>
  
  <p>I am really confused on how I got these numbers, and honestly have no idea what went wrong. I can do the rest of the program (such as the formula, printing out everything, etc.), but I don't know how to fix the charAt() problem. I know I can handle the rest of the assignment, but I have no idea what went wrong with this. If someone could provide some guidance on how to fix issue, it would be greatly appreciated. Thank you!</p>