Where am I going wrong please? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Where am I going wrong please?

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(); if(isSuspended == True){ System.out.println("Suspended"); } if(isSuspended == False){ if (ourScore == theirScore) System.out.println("Draw"); } else { if (ourScore > theirScore) System.out.println("Won"); } else { if (ourScore < theirScore) System.out.println("Lost"); } } } }

23rd Dec 2021, 2:13 AM
Peter Dunphy
2 Answers
+ 3
U made some mistakes in closing prackets. And the boolean values true and false should be lowercase. Java is case-sensitive. Here your corrected 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(); if(isSuspended){ System.out.println("Suspended"); } if(!isSuspended){ if (ourScore == theirScore) System.out.println("Draw"); else { if (ourScore > theirScore) System.out.println("Won"); else { if (ourScore < theirScore) System.out.println("Lost"); } } } } }
23rd Dec 2021, 2:35 AM
Vadivelan
0
Thank you!
3rd Feb 2022, 12:34 AM
Peter Dunphy