title: Find the Average of digits by using While Loop
body: <p>I know this is basis problem, but I just can't solve this, so I need your help..
  I am trying to find the average of digits of the number(user input) by using While Loop, like for example, the average of digits of the number 789 is (7+8+9+)/3 = 8. 
  Could anyone help me with this..? Thank you so much. </p>
  
  <pre><code>import java.util.Scanner; 
  public class AVE
  {
  
    static int digits = 0;
    static int average =0;
    static int sum =0;
    static int number;
  
  
    public static void main (String[]args)
    {
      Scanner kb = new Scanner (System.in);
      System.out.println("what is your number?");
      number = kb.nextInt();
      avDigits();
      System.out.println("The average is " + average);
    }
  
    public static void avDigits()
    {
      int num = number;
      while (num &gt; 0)
      {
        digits += 1;
        sum += digits % 10;
        num/=10;
      }
  
      average = (sum/digits);
  
     }
  }
  </code></pre>