我想我在某处遗漏了括号,但我已经搜索了 3 个小时,找不到问题所在,谷歌搜索也没有帮助我。
我尝试在 if then 语句中添加结束大括号/方括号,但随后出现了一堆错误。一旦有人发现我做了什么,可能会是一个“duh”的时刻。在此先感谢。
错误:NumberGame.java:45:错误:解析时到达文件末尾} ^ NumberGame.java:51:错误:解析时到达文件末尾 2 个错误
import java.util.*;
public class NumberGame
{
public static void main(String[] args)
{
double R = 0;
double tryit = 0;
double a = 0;
double b = 0;
while (tryit == 0)
{
R = 0;
while (R != 1)
{
a = (int)(Math.Random() * 10);
b = (int)(Math.Random() * 10);
if (a -b >= 0){
R = 1;
}
}
double inpt = -7;
while (inpt != (a-b))
{
Sytem.out.println("What is " + a + " minus " + b + " ? ");
inpt = scanner.inpt = new Scanner(System.in);
if ((a -b) == inpt){
System.out.print("Good job, you are correct");
System.out.println("Play again?, Yes or No?:");
String inpt2 = scanner.inpt2 = new Scanner(System.in);
if ((a-b) != inpt){
System.out.println("Sorry try again");
}
if (inpt2 == "No"){
System.out.println("Thanks for playing");
break;
if (inpt2 == "no"){
System.out.println("Thanks for playing");
break;
}
}