title: Sum the Digit in an integer
body: <pre><code>* Write a programe that reads an integer between 0 and 1000 and adds all the 
   * digits in the integer. For example, if an integer is 932 the sum of all its
   * digits is 14.
   */
  package sumthedigitsinaninteger;
  
  /**
   *
  */
  import java.util.Scanner;
  
  public class SumTheDigitsInAnInteger {
  
  public static void main(String[] args) 
  {
     Scanner input = new Scanner(System.in);   
  
     System.out.print(" Enter a number between 0 and 1000 : ");
  
     int  num = input.nextInt();
  
     int extract = num % 10;
  
     int remove_extract = extract / 10 ;
  
     int answer = extract + remove_extract;
  
     System.out.print(" The sum of the digit is " + answer);
  
  }    
  }
  </code></pre>
  
  <p>I am so confused about this problem. I am reading a chapter in java book called Introduction to Java Programming 9th edition by Y.Daniel Liang. This chapter is a bout elementary programing which only teach me how to declare basic variable and do basic arithmetic. When I check online for help most of help I got with for loop or while loop which I have not read it yet. Anyone know how to do this problem without for loop or while loop because I have not get to that chapter yet. I know % means a reminder of division and / means quotient. when I did this problem manual I got right answer for 932 which is 14. I got it by doing a division twice  by 10 and add a reminder of those two division which was a 3 and 2 then I add a motioned a 9 to 3+2 which gave me a 14. I am so confused how convert a this logic into source code with my little knowledge of loops. Thanks.  </p>