DEV Community

loading...

Discussion on: Daily Challenge #45 - Change Machine

Collapse
vivek97 profile image
Vivek97 • Edited
public static void change(int number)
     {      
        int [] array = {25,10,5,1};
        number = 74;
        for(int m:array)
            {
                System.out.print(m+" =>"+number/m+" ,");
                number = number%m;      
            }
    }
Collapse
alvaromontoro profile image
Alvaro Montoro

This is a nice solution in Java. But don't forget to remove the number = 74;, otherwise the function will always write the same results.