The “double” Java data type is a 64-bit floating point type that supports all numbers, including those with decimals. To accept user input decimals in Java, you must first declare a “double” variable, after which you can scan the user-submitted data and then submit that data to the aforementioned variable. The key is to correctly declare the variable, as an improperly configured variable – string, integer – will cause Java to automatically truncate the decimal. double mileage; system.out.println(“Please submit your mileage:”; scanner scanned_value = new scanner(System.in); mileage = scanned_value.nextdouble(); Writer Bio
