Methods 表达式错误的非法开始,正在使用方法

Methods 表达式错误的非法开始,正在使用方法,methods,expression,Methods,Expression,所以当我试着运行我的骰子游戏程序时,我总是在第30行附近出现非法的表达式错误。这是我的密码: import java.util.Scanner; public class DiceGame { public static void main(String[] args) { final int RANGE = 6; Scanner input = new Scanner(System.in); int userGuess = in

所以当我试着运行我的骰子游戏程序时,我总是在第30行附近出现非法的表达式错误。这是我的密码:

import java.util.Scanner;
public class DiceGame
{
    public static void main(String[] args)
    {
        final int RANGE = 6; 
        Scanner input = new Scanner(System.in);
        int userGuess = input.next();
        int throwResult = throw2Dice(RANGE); 
        int programGuess = throw2Dice(RANGE);


        int userError = Math.abs(throwResult - userGuess);
        int programError = Math.abs(throwResult - programGuess); 
        boolean userWins = false; 
        if(userError < programError)
        {
            userWins = true; 
        {
        System.out.println("Your guess was: " + userGuess + " the program's guess was: " + programGuess + " and the result was: " + throwResult); 
        if(userWins == false)
            System.out.println("Program Wins!!!");
        else
            System.out.println("User Wins!!!"); 
    }


    public static int throw2Dice(int r)
    { 
        int number1 = (Math.random() * r + 1);
        int number2 = (Math.random() * r + 1);
        int sum = number1 + number2; 
        return sum; 
    }
}
import java.util.Scanner;
公营骰子游戏
{
公共静态void main(字符串[]args)
{
最终整数范围=6;
扫描仪输入=新扫描仪(System.in);
int userGuess=input.next();
int throwResult=throw2Dice(范围);
int PROGRAMEGUESS=throw2Dice(范围);
int userError=Math.abs(throwResult-userGuess);
int programError=Math.abs(throwResult-programGuess);
布尔userWins=false;
如果(用户错误<程序错误)
{
userWins=true;
{
println(“您的猜测是:“+userGuess+”,程序的猜测是:“+programGuess+”,结果是:“+throwResult”);
如果(userWins==false)
System.out.println(“程序赢!!!”;
其他的
System.out.println(“用户赢!!!”;
}
公共静态int-throw2Dice(int-r)
{ 
int number1=(Math.random()*r+1);
int number2=(Math.random()*r+1);
整数和=number1+number2;
回报金额;
}
}
if(userError

你有两个开口大括号,而不是一个开口大括号和一个闭合大括号。

太棒了,谢谢你。那个小错误让我非常沮丧。
if(userError < programError)
{
    userWins = true; 
{