title: Sum all digits of a number and show the digits separately in Java
body: <p>I've been using this site quite a lot but I've never really wrote anything.
  Today, I've stumbled upon a problem which solution I can't seem to find.</p>
  
  <p>The problem is that, I have an <code>int variable</code> with an unknown number of digits. It is asked of me to sum all of those digits and then have it printed/shown_as_a_message with all those digit separated.</p>
  
  <p>For example, the user enters the number "12345678" and in the end I need to have a message saying "The numbers 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 = 36". I know how to separate and sum all of those numbers, but I don't know how to save each number and then have it shown, because not only do I not know the right amount of digits, but I don't know their values either.</p>
  
  <p>Usually that wouldn't be hard to do, but here comes the tricky part for me, since we haven't learned things like <code>arrays</code>, <code>strings</code>, indexes, etc., we're not allowed to use them. So, I'm supposed to do it with the simplest type of code possible.</p>
  
  <p>So far, I've got the following:</p>
  
  <pre><code>import java.util.Scanner;
  public class Numbers {
      public static void main(String[] args) {
          int number, result;
          Scanner sc = new Scanner(System.in);
          System.out.println("Enter number:");
          number = sc.nextInt();
          result = 0;
          while (number &gt; 0){
              result = result + (number % 10);
              number = number / 10;
          }
          System.out.println("This is where the message would go.");
      }
  }
  </code></pre>