import java.util.Scanner;
public class ArithmeticDemo {
public static void main(String[] args)
{
int firstNumber;
int secondNumber;
int sum;
int difference;
int average;
Scanner input = new Scanner(System.in);
System.out.print("Please enter a double >> 14");
firstNumber = input.nextInt();
System.out.print("Please enter another double >> 11 ");
secondNumber = input.nextInt();
sum = firstNumber + secondNumber;
difference = firstNumber - secondNumber;
average = sum/2;
System.out.println(firstNumber + " + " + secondNumber + " is " + sum);
System.out.println(firstNumber + " - " + secondNumber + " is " + difference);
System.out.println("The average of " + firstNumber + " and " + secondNumber + " is " + average);
}
}
我做學校功課,一切似乎沒什麼問題,在我一眼,甚至休息了一下,回來,但執行掃描儀只讀取第一行
Please enter an integer >> 14
Please enter another integer >> 11
14 + 11 is 25
14 - 11 is 3
The average of 14 and 11 is 12
當代碼應該顯示
但是,當我執行它,它只是
Please enter an integer >> 14
我使用Eclipse讀取並統計有錯我的掃描儀輸入的命令,但我不確定它是什麼,感謝您的幫助。
好吧,我是編程新手,我正在使用eclipse,並且完全不瞭解該程序,但是我做了編輯並能夠將它上班謝謝你,你和Alex正確 –