0

I can't understand what's wrong with my code.

import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner read = new Scanner(System.in); boolean isSuspended = read.nextBoolean(); int ourScore = read.nextInt(); int theirScore = read.nextInt(); // your code goes here if(isSuspended){ System.out.println("Suspended"); } else { if (ourScore>theirScore); { System.out.println("Won"); } if (ourScore<theirScore); { System.out.println("Lost"); } if (ourScore==theirScore); { System.out.println("Draw"); } } } I have an error /usercode/public class Main.java:25: error: reached end of file while parsing } ^. Other than that, I cannot use else because it cannot bind to an if. How do I finish the code correctly, what is wrong with it?

5th Aug 2021, 8:18 AM
Андрей Хоменко
Андрей Хоменко - avatar
2 ответов
+ 3
You are missing a curly bracket at last for the opening bracket of Main function. Also putting a semicolon immediately after if condition terminates it and whatever is in curly bracket is printed normally with no relation to any of the condition.
5th Aug 2021, 8:40 AM
Abhay
Abhay - avatar
+ 1
Thanks, I've just added one extra curly bracket, and have deleted all the semicolons after all if conditions (with the exception of the first condition "isSuspended").
5th Aug 2021, 8:48 AM
Андрей Хоменко
Андрей Хоменко - avatar