我刚开始学习java。我正在尝试制作一个采用十进制的程序。但是当我输入小数时它给我错误
I just started to learn java. I am trying to make a program that takes in decimal. But it gives me error when i enter a decimal
包 com.Pramesh;
导入java.util.Scanner;
public class PrameshShrestha {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("Enter your first number");
double num1 = input.nextDouble();
System.out.println("Enter your second number");
double num2 = input.nextDouble();
System.out.println("The total is: " + (num1 + num2));
}
}
要输入双数,例如 2.5 你需要在控制台上写 2,5
包 com.Pramesh;
导入java.util.Scanner;
public class PrameshShrestha { public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("Enter your first number");
double num1 = input.nextDouble();
System.out.println("Enter your second number");
double num2 = input.nextDouble();
System.out.println("The total is: " + (num1 + num2));
}
}
要输入双数,例如 2.5 你需要在控制台上写 2,5