Java 我的循环不会继续进行下一步

Java 我的循环不会继续进行下一步,java,Java,我的循环有问题 public static void me() { Scanner input = new Scanner(System.in); DecimalFormat df = new DecimalFormat("##0.00"); int mew = 0; double mes = 0; boolean Curve = true; int cBool = 0; double cNum = 0; double mers =

我的循环有问题

public static void me() {
    Scanner input = new Scanner(System.in);
    DecimalFormat df = new DecimalFormat("##0.00");
    int mew = 0;
    double mes = 0;
    boolean Curve = true;
    int cBool = 0;
    double cNum = 0;
    double mers = 0;
    double wmes = 0;

    //Input Midterm weight and score
    System.out.println("\nMidterm exam:");
    System.out.print("\tWhat is its weight (0-100)? ");
    mew = input.nextInt();
    System.out.print("\tExam Score ");
    mes = input.nextDouble();
    while (Curve){
        System.out.print("\tWas there a curve? (1 for yes, 2 for no) ");
        cBool = input.nextInt();
        if (cBool == 2)
            Curve = false;
        else
        System.out.print("\tHow much was the curve? ");
        cNum = input.nextDouble();
        Curve = false;
    }

    //calculate weighted Midterm score
    mers = (mes+cNum);
    if (mers > 100)
            mers = 100;
    wmes = ((mers/100)*mew);
    System.out.println("\tWeighted Exam score: " + df.format(wmes));}
}

问题是,当我为cBool输入2时,它将不会继续执行下一步,但是如果我为cBool输入1,然后为cNum提供一个数字,它将继续执行下一步

是否尝试隔离else块中存在的所有指令? 由此:

else
System.out.print("\tHow much was the curve? ");
cNum = input.nextDouble();
Curve = false;
为此:

else
{

 System.out.print("\tHow much was the curve? ");
    cNum = input.nextDouble();
    Curve = false;

}

您正在设置
Curve=false
在第一次迭代后退出while循环。根据您已有的代码,当cBool==2时,您已经设置了Curve=false。因此,它不会继续下去,对于任何输入,rloop只会运行一次。此外,如果else部分是复合语句,请将其括在大括号中。else{System.out.print(“\t曲线多少?”);cNum=input.nextDouble();curve=false;}始终在
{
if和
else
行之后使用
{/code>。否则,您会得到像这样的意外结果。这会迭代吗?当输入为
3
1
时需要什么?那么还需要循环吗?