我收到一个语法错误,我不知道为什么。我正在学习编程课程,所以我的知识非常有限。这是我必须做的一个项目,也是我目前拥有的代码。我只是想测试一下,看看我是否走在正确的道路上,但我做不到。任何帮助都会非常感激,所以我至少可以看到我的下一个问题是什么哈哈。
import java.util.*;
public class project2 {
public static void main(String[] args) {
Scanner in = new Scanner (System.in);
System.out.println("Welcome, I am thinking of a number between 1-100. Take a guess!");
System.out.print("Please enter your number: ");
int guess = in.nextInt();
Random r = new Random(101);
int counter = 0;
int totalcount = 6;
While (counter != totalcount) { // being told to insert ";" and I have no clue why
if ( guess < r) {
System.out.print("You guessed " + guess);
System.out.println("Too Low");
} else if ( guess > r) {
System.out.print("You guessed " + guess);
System.out.println("Too High");
} else ( guess = r ) {
System.out.print("You guessed " + guess);
System.out.println("YOU'RE PSYCHIC!");
}
counter++;
}
}
}