/*
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 void main(String[] args) {
        System.out.println("Welcome to Online IDE!! Happy Coding :)");
        
        System.out.println("This is answer:" + expandedForm(257.24));
    }
    
    public static String expandedForm(Double number)
    {
        String convertedNumber = Double.toString(number); 
       
        //problem has to be treated as two parts... string before and after decimal place.
        
        int positionDecimalPoint= convertedNumber.indexOf('.');   //zero based notation  it would be 3 in above example
        int remainingChars;
        int roundedNearestUnit;
        int count=1;
        
        String charsBeforeDecimal = convertedNumber.substring(0,positionDecimalPoint);
        String charsAfterDecimal = convertedNumber.substring(positionDecimalPoint+1,convertedNumber.length());
        
        int lengthCharsBeforeDecimal = charsBeforeDecimal.length();
        int lengthCharsAfterDecimal =  charsAfterDecimal.length();
        
        System.out.println(charsBeforeDecimal);
        System.out.println(charsAfterDecimal);
        
        for (int i=0; i<convertedNumber.length();i++)
        {
            if (i<=positionDecimalPoint)  // this would be 3 in  257.24
            {
                System.out.println("i: " + i);
                
            //need to create alternate int and round down nearest 100
            //need to know number remaining chars in String
            
            remainingChars = convertedNumber.length()-1;
            
            // Now remaining characters is used in  10 ^  remainingChars
            // for instance  247  will give  2 x (10 ^ 2) = 200
            
            int prefix = Character.getNumericValue(convertedNumber.charAt(0)); 
            
            System.out.println("prefix:" + prefix);
            
            roundedNearestUnit =  (int) (Math.pow(10,lengthCharsBeforeDecimal-count) * prefix);
            System.out.println("rounded down:" + roundedNearestUnit);
            
            convertedNumber=convertedNumber.substring(1,remainingChars);
            
            
            
            System.out.println("processing: " + convertedNumber);
            count++;
            
            
            Double remainingPart = Double.parseDouble(convertedNumber);
            
            String createString = Integer.toString(roundedNearestUnit);
            
            return createString + expandedForm()
            
        }
    }
        
        
        return null;
        
    }
    
}
