package hw.loops.co.il;
import java.util.Scanner;
public class LoopsTargilMedium3 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int num;
do {
System.out.println("Please enter a number:");
num = input.nextInt();
if (num%2==0) {
System.out.println("The number " + num + " is ZUGI");
}
else {
System.out.println("The number " + num + " is E-ZUGI");
num++;
} while (num!=-1);
System.out.println("loop stoped");
}
}
}
收到此错误:
Exception in thread "main" java.lang.Error:
Unresolved compilation problem:
Syntax error, insert "while ( Expression ) ;" to complete DoStatement
最佳答案
您在 while 之前放错了右括号:
..
} //<-- missing this
}while (num!=-1);
System.out.println("loop stoped");
...
关于java - 语法错误,while/do 表达式,,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51206184/