0

Please help this poor kid on what he left out or didn't properly input

public class Program { public static void main(String[] args) { int criminals = 7; if (criminals < 5) {System .out.println ("I got this!"); } else if (criminals <= 10) {System .out.println ("Help me Batman"); } else {System .out.println ("Good luck out there!");} } } Thats my code i used java.

6th Apr 2021, 6:20 PM
Eren Thobo
Eren Thobo - avatar
5 Answers
+ 2
As far as I can tell, this should run. What's the behavior you're *trying* to get? Are you trying to get input based on user input? If so, then yes, you'd need to follow @ChaoticDawg 's advice and do: Scanner scanner = new Scanner(System.in); int criminals = scanner.nextInt(); As it stands, this program checks the value of "criminals" to see if it's: A) less than 5, B) between 5 and 10, or C) over 10. And outputs one of the three strings depending on the output.
6th Apr 2021, 7:53 PM
HealyUnit
HealyUnit - avatar
+ 1
You need to get the number of criminals as an input int. Use a Scanner and get the nextInt() for the number of criminals.
6th Apr 2021, 6:35 PM
ChaoticDawg
ChaoticDawg - avatar
+ 1
It's the Gotham City code coach. In order to solve, input must be taken as an int. Then correct output is given depending on the number.
6th Apr 2021, 7:57 PM
ChaoticDawg
ChaoticDawg - avatar
0
What is the problem with this code? Do you want to take input by this code? Pls add it clearly..
6th Apr 2021, 6:35 PM
Jayakrishna 🇼🇳
0
There are five test cases i should get right and out of these im managing to get the second test case correct. (If it helps) Yes i am definitely trying to get input based on user input and i believe the scanner class hasn't been introduced to me yet, so I'm unfamiliar with it.
7th Apr 2021, 3:11 PM
Eren Thobo
Eren Thobo - avatar