Gotham City Java | Sololearn: Learn to code for FREE!

0

Gotham City Java

Whenever I test the code it works with different numbers, but it doesn't pass the test when I put it in. Can someone point me in the right direction of what I'm doing wrong? int criminals = 1; if ( criminals < 5 ) { System.out.println("I got this!"); } else if( criminals <= 10) { System.out.println("Help me Batman"); } else if( criminals > 10) { System.out.println("Good Luck out there!"); }

2/18/2020 11:32:29 PM

Josh Ely

8 Answers

New Answer

+4

how are you getting the input? if that's the whole code. you need: at the very top import java.util.Scanner ; Scanner inp = new Scanner(System.in) ; int x = inp.nextInt(); remove: int criminals = x; the rest is ok.

+3

Don't forget to import the scanner library: import java.util.Scanner;

+3

En la segunda condicional te falta agregar la condicion que sea mayor de 5. For example: criminals>=5 && criminals<=10

+3

Ok. So I think I'm getting ahead of myself with this one. I haven't learned about scanners yet.

0

Sorry. I edited it to show how I actually had it in the system. I copy pasted the wrong one.

0

Increment that criminals variable

0

in the first else if statement, you should check if criminals is greater than or equal to (>=) and less than 10. So basically it is: criminals >= 5 && criminals < 10

0

import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int criminalCount = sc.nextInt(); if(criminalCount < 5){ System.out.println("I got this!"); } else if(criminalCount>=5 && criminalCount<=10){ System.out.println("Help me Batman"); } else{ System.out.println("Good Luck out there!"); } } }