我被卡在U of Helsinki Java MOOC中:
创建一个可用于将两个整数相加的程序。首先,要求用户给出两个要求和的整数。然后,程序将打印描述数字加法的公式。
示例输出:
Give the first number: 5 Give the second number: 4 5 + 4 = 9
我试图让系统打印“” first“ +” second“是” result“。出于某种原因,我陷入了这个原本很简单的问题。我的代码总是抛出错误。最后一行?
import java.util.Scanner;
public class AdditionFormula {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
// write your program here
System.out.println("Give the first number: ");
int first = Integer.valueOf(scanner.nextLine());
System.out.println("Give the second number: ");
int second = Integer.valueOf(scanner.nextLine());
//System.out.println("first" " + " Integer.valueOf(first) + Integer.valueOf(second));
System.out.println(first + " + " + second " = " + (first + second));
}
我陷入了赫尔辛基Java MOOC的难题:创建一个程序,该程序可用于将两个整数加在一起。首先,要求用户给出两个要求和的整数。 ...