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.
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.
+ 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.
+ 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.
0
What is the problem with this code? Do you want to take input by this code? Pls add it clearly..
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.