Exception in thread "main" java.util.IllegalFormatConversionException: d != java.lang.String

Solution 1:

The problem is here:

System.out.printf("%d has ", number + "digits.");

the %d format specifier requires an integer to be passed as second parameter to printf, but by concatenating number and "digits.", you actually passed a String.

Fixed version:

System.out.printf("has %d digits ", number);

note that you cannot print both the original number and the number of digits, because you overwrote one with the other in the number variable. Maybe use two different ones.