This program should count amount of digits in a number.
Here is my code:
import java.util.Scanner;
public class Converter {
public static void main(String[] args) {
Scanner marty = new Scanner(System.in);
float sk;
System.out.println("Enter start number: ");
sk = marty.nextFloat();
int numb = (int)Math.log10(sk)+1;
System.out.println(numb);
marty.close();
}
}
I am getting this kind of error, while tryin to input number with 4 or more digits before comma, like 11111,456:
Exception in thread "main" java.util.InputMismatchException
at java.util.Scanner.throwFor(Unknown Source)
at java.util.Scanner.next(Unknown Source)
at java.util.Scanner.nextFloat(Unknown Source)
at Converter.main(Converter.java:11)
Any ideas about what the problem may be?