Java 我的中断声明没有';它似乎工作不正常,执行后仍会循环一次

Java 我的中断声明没有';它似乎工作不正常,执行后仍会循环一次,java,Java,首先让我说,我是一个相对较新的程序员,几乎没有经验,如果我的问题对某些人来说可能很容易,我很抱歉。我需要编写一个程序,使用while循环向用户提问,如果他们有某个数字或更高,他们将得到某个响应,如果没有,他们将被告知再试一次。我想我大部分都做对了,但每次我输入正确的数字,它不会立即中断,并在停止前循环一次 public class TaffyTester { public static void main(String[] args) { System.out.p

首先让我说,我是一个相对较新的程序员,几乎没有经验,如果我的问题对某些人来说可能很容易,我很抱歉。我需要编写一个程序,使用while循环向用户提问,如果他们有某个数字或更高,他们将得到某个响应,如果没有,他们将被告知再试一次。我想我大部分都做对了,但每次我输入正确的数字,它不会立即中断,并在停止前循环一次

public class TaffyTester
{
    public static void main(String[] args)
    {
        System.out.println("Starting the Taffy Timer...");
        System.out.print("Enter the temperature: "); 
        while (true)
        {
            Scanner input = new Scanner(System.in);
            int temp = input.nextInt();
            System.out.println("The mixture isn't ready yet.");
            System.out.print("Enter the temperature: ");
            if (temp >= 270)
            {
                System.out.println("Your taffy is ready for the next step!");
                break;
            }
        }
    }
}

我会改变顺序,这样更符合逻辑

    System.out.println("Starting the Taffy Timer...");
    Scanner input = new Scanner(System.in);
    int temp = 0;
    while (temp < 270)
    {
        System.out.println("The mixture isn't ready yet.");
        System.out.print("Enter the temperature: ");
        temp = input.nextInt();
    }
    System.out.println("Your taffy is ready for the next step!");

执行的代码是“启动Taffy定时器…输入温度:800混合物尚未准备好。输入温度:您的Taffy已准备好进行下一步!”我希望代码仅在温度等于或高于270时说“您的Taffy已准备好进行下一步!”,对不起,如果我没说清楚的话earlier@Ali-请检查你的代码是否与我的相同。我也添加了输出。
中断是在循环中还是在
中?
Starting the Taffy Timer...
The mixture isn't ready yet.
Enter the temperature: 800
Your taffy is ready for the next step!