0
ブール値のフラグを設定しようとしているため、ユーザーは 'S'と 'Q'を選択する前に 'M'(生徒の回答をマーク)を入力する必要があります。彼らがこれらを選んだら、「統計を入力する前に答えを記入してください」というメッセージがあるはずです。残りのオプションは常にユーザーが利用できるはずですが、ユーザーは 'S'と 'Q'を選択する前に 'M'を選択する必要があるようにブール値を設定する方法がわかりません。誰でもこれを行う方法を知っていますか?ここに私のコードは、これまでのところです:ユーザーメニューでブール値を設定する方法は?
public class Marker_Menu
{
public static void main(String args[])throws IOException
{
Quiz_Marker input2 = new Quiz_Marker();
char arg[]= null;
System.out.println ("Welcome to the Quiz Grading System \n");
char choice = menu();
while(choice != 'E')
{
switch (choice)
{
case 'C':
input2.corAnsPrint();
break;
case 'A':
input2.stuAnsPrint();
break;
case 'M':
input2.quizMarking();
break;
case 'S':
input2.stuStatsPrint();
break;
case 'Q':
input2.quesStatsPrint();
break;
default:
System.out.println("Your choice is invalid");
}
choice = menu();
}
System.out.println("Thank you for using the Quiz Marker System");
System.exit(0);
}
public static char menu() throws IOException
{
System.out.println ("Please enter your choice \n" +
" C - Print Correct Answers \n" +
" A - Print Student Answers \n" +
" M - Mark the Student Answers \n" +
" S - Produce the Quiz Statistics \n" +
" Q - Produce Question Statistics \n" +
" E - Exit the System");
Scanner input = new Scanner (System.in);
char choice = input.next().toUpperCase().charAt(0);
return choice;
}
}
感謝を!出来た。 – Srk93