我在 JCreater 中运行它,但我不断收到编译错误。我做错了什么?我看到有人将所有值都设置为 0.0,但我不明白我为什么需要它。
import java.util.Scanner;
public class C2p3 {
public static void main(String[] args) {
double num1, num2, sum, difference, product; //setting variables
Scanner scan = new Scanner(System.in);
System.out.println("Enter first number:");
num1 = scan.nextDouble(); // not really sure what it does but I always use it and it works fine
System.out.println("Enter second number:");
num2 = scan.nextDouble();
sum = num1 + num2;
product = num1 * num2;
difference = num1 - num2;
System.out.println("Sum = " + sum);
System.out.println("Product = " + product);
System.out.println("Difference =" + difference);
}
}