public static void main(String[] args) {
//call for input
System.out.println("Please Enter a 3-digit number..");
Scanner in = new Scanner(System.in);
int[] num = new int[3];
for (int i = 0; i < num.length; i++) {
int val = in.nextInt();
num[i] = val;
}
System.out.println("The Sum of the numbers is " + sumNums);
System.out.println("The Reverse of the numbers is " + reverseNums);
}
public int sumNums(int x) {
return num[0] + num[1] + num[2];
}
public in reverse(int x) {
return num[2] + num[1] + num[0];
}
我想創建一個方法來添加一個分解數字,例如,如果我輸入123,它會導致1 + 2 + 3 = 6,但我不斷收到「找不到標誌」。也是我分手輸入效率最高的方式嗎?用Java處理輸入
您需要了解變量和參數如何工作。 – SLaks