我还在学习http://programmingbydoing.com/a/name-age-and-salary.html
我收到此错误消息。谁能告诉我如何解决这个问题? 如果我输入数字99.9,我会收到此错误。但如果我把99或99,9这不是错误。 i get this error
import java.util.Scanner;
public class NameAgeSalary
{
public static void main ( String[] args)
{
Scanner keyboard = new Scanner (System.in);
String Name;
int Age;
double Salary;
System.out.println( "Hello. What is your name?" );
Name = keyboard.next();
System.out.println();
System.out.println( "Hi, " +Name+ "! How old are you?" );
Age = keyboard.nextInt();
System.out.println();
System.out.println( "So you're " +Age+ ", eh? That's not old at all! ");
System.out.println( "How Much do you make," +Name+ " ?" );
Salary = keyboard.nextDouble();
System.out.println();
System.out.println( ""+Salary+ "! I hope that's per hour not per year! LOL!");
}
}
答案 0 :(得分:0)
如果双重接受99和99,9,但99.9不接受,则将您的语言环境设置为逗号用作小数分隔符而不是点的值。
例如在美国,值1,234.56是正确的,而德国的相同数值则表示为1.234,56。
请检查语言和本地设置,并根据该设置输入值。