I have this,
import java.util.Scanner;
public class StringDecimalPartLength {
public static void main(String[] args){
Scanner input = new Scanner(System.in);
System.out.print("Enter a decimal number: ");
Double string_Temp = Double.parseDouble(input.nextLine().replace(',', '.'));
String string_temp = Double.toString(string_Temp);
String[] result = string_temp.split("\\.");
System.out.print(result[1].length() + " decimal place(s)");
}
}
it works until I enter a number with trailing zero, such as 4,90. It ignores the zero and returns 1.
How to fix this? Thank you!