我在尝试将哨兵退出键设置为退出的底部遇到了麻烦。我不确定我应该怎么做。
整数;
do
{
Scanner Input = new Scanner(System.in);
System.out.print("Enter a positive integer or q to quit program:");
number = Input.nextInt();
}
while(number >= 0);
do
{
Scanner Input = new Scanner(System.in);
System.out.print("Input should be positve:");
number = Input.nextInt();
}
while(number < 0);
do
{
Scanner quit = new Scanner(System.in);
System.out.print("Enter a positive integer or quit to end program");
input = quit.nextstring();
}
while (!input.equals(quit))//sentinel value allows user to end program
{
quit = reader.next()