This an example input:
1002372
I need to get an output like this:
0012237
I am required to use loops, and boolean algebra.
I've converted the int
into a String
and I tried this for a start:
x = String.valueOf(a);
y = String.valueOf(b);
for(int z = 0; z < x.length(); z++)
{
if(x.charAt(z) == '0')
{
System.out.println(x.charAt(z));
}
if(x.charAt(z) == '1')
{
System.out.println(x.charAt(z));
}
}
Instead of running through and finding all the zeros first, the program just prints the numbers in order.
How do I check and print all of one integer at a time?