+ 1
Hey, does anyone know how to solve this code? Im stuck on it for so long. Thanks in advance
8 Antworten
+ 2
Vizznet 
Because this condition if(isSuspended = true) is wrong.
There should be double equal. 
Instead of doing that just do this:
if (isSuspended) {
}
No need to compare with true.
+ 2
import java.lang.Exception; 
import java.util.Scanner;
public class Main {
   public static void main(String[] args) {
        try {
            Scanner read = new Scanner(System.in);
            boolean isSuspended = read.nextBoolean();
            int ourScore = read.nextInt();
            int theirScore = read.nextInt();
            if(isSuspended) System.out.println("Suspended");
            else {
                if(ourScore > theirScore) System.out.println("Won");
                else if(theirScore > ourScore) System.out.println("Lost");
                else System.out.println("Draw");
            }
        } catch (Exception e) {
            System.out.println("Error");
        }      
   }    
}
/*
Input that:
false
10
10
*/
// Happy coding and keep learning.
+ 2
Vizznet 
That 3 parts should be inside else part. 
If match is suspended then no need to check anything. So you should check everything inside else part.
+ 1
Vizznet 
It is very simple. First check suspended then do rest in else part like:
if(isSuspended) {
         System.out.println("Suspended");
} else {
      //rest condition should be inside this part
}
+ 1
Im sorry but i still dont get it i cant use the else statement because theres 3 parts that have to be checked
+ 1
Vizznet 
Whatever I am telling just do that and tell me if I am wrong.
+ 1
I did it (i think), but it outputs as suspended everytime 
https://code.sololearn.com/cenyhK72TCxh/?ref=app
+ 1
Thank you for helping me sir! I understand now



