/*
Online Java - IDE, Code Editor, Compiler

Online Java is a quick and easy tool that helps you to build, compile, test your programs online.
*/

public class Main
{
    public static int digitCount(int value)
    {
        while (value!=0)
        {
            int digit = value%10;   // this presents remainder... So 12345 % 10 will always present last digit
                                    //since 12340 is fully divisible by 10
                                    // Likewise for 1234 % 10, it will present last digit as 4
                                    //since 1230 is fully divisible by 10
            
            System.out.println("\nThis is digit: " + digit);
            
            value=value/10;   // the new value to be passed into recursive call is 1234 since 12345/10 is   (int) 1234.5 = 1234; 
            
            System.out.println("This is digit removed: " + digit + " => " + value);
            return 1 + digitCount(value);  // this is used to keep a count recursively of number executions (number of digits)
            //the value also drops last digit each time
        }
        
     return 0;   
    }
    
    public static void main(String[] args) {
        System.out.println("Welcome to Online IDE!! Happy Coding :)");
        
        // count number digits in integer using recursion
        // perhaps need to put each
        
        int value = 12345;
        System.out.println("This is the original value: " + value);
        System.out.println("\nNumber of digits: " + digitCount(value));
    }
}

