I tried use scanner at easiest way:
Code:
double gas, efficiency, distance, cost;
Scanner scanner = new Scanner(System.in);
System.
You should precise a Locale for your Scanner.
Scanner scanner = new Scanner(System.in).useLocale(Locale.US);
From the doc :
An instance of this class is capable of scanning numbers in the standard formats as well as in the formats of the scanner's locale. A scanner's initial locale is the value returned by the Locale.getDefault() method; it may be changed via the useLocale(java.util.Locale) method
The localized formats are defined in terms of the following parameters, which for a particular locale are taken from that locale's DecimalFormat object, df, and its and DecimalFormatSymbols object, dfs.
So your default locale use certainly a DecimalFormat that expect a comma as a decimal delimiter instead of a dot.
Make sure that you are using the correct locale
Scanner scanner = new Scanner(System.in).useLocale(Locale.US);
Maybe you are using a locale where "," is the decimal delimiter