Hello.
/>/>
I was wondering whether anyone could tell me, whether I have written the below program correctly:
/>
Because 'n' is currently set to 10, the program is supposed to output the result:
0
1
(It should start at 0 and count up 1 for every digit in the value of 'n'.)
But at the moment, it only outputs 1, no matter what I set 'n' to.
Any help/assistance would be greatly appreciated.
I was wondering whether anyone could tell me, whether I have written the below program correctly:
import java.util.*;
public class Task5bDW
{
public static void main(String[] args)
{
int d = 0;
int i = 0;
int n = 10;
do {
d++;
n /= 10;
} while ((d == 0) && (n != 0));
System.out.println(d);
}
}
Because 'n' is currently set to 10, the program is supposed to output the result:
0
1
(It should start at 0 and count up 1 for every digit in the value of 'n'.)
But at the moment, it only outputs 1, no matter what I set 'n' to.
Any help/assistance would be greatly appreciated.