title: Java - Write a program that prompts the user to input an integer and then outputs both the individual digits of the number and the sum of the digits
body: <p>I have seen this question asked a few times, but all of the responses have included functionality that I haven't learned yet in this class and am I sure there must be a way to do it with only what I have learned.  No arrays, etc... just loops and prior.  I am not really looking for the answer, but just some direction.  I have included the code I have already done.  The program needs to be able to hand negative numbers, the sum and then print in the proper order.  Right now my code does everything except print in the proper order.  I understand why it is printing in reverse order (because the loop gets rid of and then prints the last number in the int), but I can't seem to figure out a way to change it.  I have tried converting it to a string, char and just can't get it.  Please take a look, and provide some guidance if you don't mind.  thank you in advance.</p>
  
  <pre><code>    public static void main(String[] args) {
          int num;
          int sum;
          int temp;
  
          System.out.print("Enter an integer, positive or negative: ");
          num = keyboard.nextInt();
          System.out.println();
  
          if (num &lt; 0)
              num = -num;
  
          sum = 0;
  
          while (num &gt; 0) {
              temp = num;
              sum = sum + num % 10;           //Extracts the last digit and adds it to the sum
              num = num / 10;                 //removes the last digit
              System.out.print(temp % 10 + " ");
          }
  
          System.out.println(" and the sum is " + sum);
      }
  }
  </code></pre>