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 Answers
+ 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