0
我在Java中編碼,我必須創建一個接受用戶輸入的程序,我已經完成了。但我很困惑,我可以用什麼語句列出用戶輸入的整數。如何創建用戶輸入列表?
這是我到目前爲止有:
//Biker's Journey Program
import java.util.Scanner;
public class lab2
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
int w;
int x;
int y;
int z;
int result;
System.out.print("Please enter the first day's traveled miles: ");
w = input.nextInt();
System.out.print("Please enter the second day's traveled miles: ");
x = input.nextInt();
System.out.print("Please enter the third day's traveled miles: ");
y = input.nextInt();
System.out.print("Please enter the last day's traveled miles: ");
z = input.nextInt();
System.out.print("The number of miles traveled was: ");
System.out.println()
result = (w + x + y + z)/4;
System.out.printf("The average miles per day traveled is %d\n", result);
}
}
而且這個代碼段並計算,我只是無法弄清楚如何得到這樣列出這幅畫的整數:http://imgur.com/KFNkWEd
謝謝你,Jeroen。我一整天都被困住了。 – Monteezy
好的,所以如果它很好,也許你可以把這個標記爲解決方案? –