因此,在我的程序的這一部分,我試圖讓程序重新詢問用戶的輸入。使while循環重新詢問用戶的輸入
問題是說int已經被聲明瞭。但是,我如何再次獲得有關問題的輸入?
Scanner keyboard = new Scanner(System.in);
System.out.println("Please enter possible and actual points for participation: ");
int pparticipation = keyboard.nextInt();
int aparticipation = keyboard.nextInt();
while (aparticipation > pparticipation || pparticipation < 0){
System.out.println("Please enter possible and actual points for participation: ");
int pparticipation = keyboard.nextInt();
int aparticipation = keyboard.nextInt();
}
哇愚蠢的錯誤。感謝您指出它,這就是訣竅! – 2013-03-02 02:15:59