我試圖讓我的代碼重複,我試着輸入「而」但它說:如何讓我的程序循環?
表達的非法啓動。
任何幫助將不勝感激哪裏可以進入這個。
import java.util.Scanner;
public class GasMileage
{
public static void main(String[ ] args)
{
Scanner keyboard = new Scanner(System.in);
System.out.print("How many miles were driven?");
int miles;
miles = keyboard.nextInt();
System.out.print("How many gallons were used?");
int gallons;
gallons = keyboard.nextInt();
int mpg;
mpg = miles/gallons;
System.out.println(" The Miles-Per-Gallon used in this trip are " + mpg);
}
}
歡迎來到StackOverflow!我編輯了您的問題以添加最重要的標記:Java。我還縮進了您提供的代碼以提高可讀性。請使用'while'添加代碼行,以便我們可以看到您正在嘗試執行的操作。 – trincot