title: Analyze a two digit number and print sum of its individual digits
body: <p>I'm trying to make a program that can analyse a two digit number from user. I used a <code>Scanner</code> object to take the input and later an array combination. This is my code:</p>
  
  <pre><code>class Calculate {
      public static void calculate() {
          Scanner br = new Scanner(System.in);
  
          int[] c = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
          int[] d = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
  
          int sum;
          int a = br.nextInt();
          System.out.println("Digit is:" + a);
  
          for (int i = 0; i &lt; 10; i++) {
              int e = 0;
              if (a == ((c[i] * 10) + d[e])) {
                  sum = ((c[i] * 10) + d[e]);
                  System.out.println("First digit is:" + c[i] 
                          + " Second digit is:" + d[e] 
                          + "\n" + "Sum of digits=" + sum);
              } else if (i == 9) {
                  i = 0;
                  e++;
              } else if (e == 10) {
                  System.out.println("INVALID NO. HAS BEEN DETECTED");
              }
          }
      }
  }
  </code></pre>
  
  <p>My expected output (for e.g. if user enters 56):</p>
  
  <pre><code>Digit is:56 
  First Digit:5 Second digit:6
  Sum of digits=11
  </code></pre>
  
  <p>However, the output is not coming out properly; it is taking infinite inputs.Like this:</p>
  
  <pre><code>56
  Digit is:56
  23
  89 
  45 
  .....
  </code></pre>
  
  <p>And this way, it's stuck in a loop. How can I correct this?</p>