-1
내가 내 루프에 문제가 다음 단계로 계속되지내 루프는
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));}
}
내가 2 cBool 것이 내가 1을 입력하지만 경우, 다음 단계로 진행되지 않습니다 입력 할 때 문제가
cBool 다음 cNum 번호를 부여하면 다음 단계로 넘어갑니다
곡선 = false로,'을 종료 while 루프는 첫 번째 반복 후에 발생합니다. – nullpointer
코드에서 cBool == 2 일 때 이미 Curve = false를 설정하고 있습니다. 따라서 더 이상 계속되지 않으므로 rloop은 anyinput에 대해 한 번만 실행됩니다 –
else 부분이 복합 문인 경우 중괄호로 묶습니다. else { System.out.print ("\ t 커브는 어느 정도입니까?"); cNum = input.nextDouble(); Curve = false; } –