Reputation: 33
First of all, I've read the many threads about this error, but none solved my problem.
Here's my code:
import java.util.Scanner;
public class Programa1 {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
double strana_a, strana_b, strana_c;
strana_a = s.nextDouble();
//strana_b = s.nextDouble();
//strana_c = s.nextDouble();
System.out.println(strana_a);
s.close();
}
}
When I type 8.0 for example, it shows me this error, what am I doing wrong?
Upvotes: 3
Views: 3022
Reputation: 6125
As told in my previous comment (I'd like to convert it into an answer), it's a problem of the Locale (from the variables' names, it seems that you're Italian). Use comma instead as point (8,5
, and not 8.5
), or initialize the Scanner using the proper Locale for point, like this:
Scanner scanner = new Scanner(System.in).useLocale(Locale.US);
Upvotes: 2