+ 1
Problem in gotham city code
import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner sc = new Scanner ( System.in); System.out.println("WELCOME TO GOTHAM CITY AND YOU ARE RECRUITED AS A POLICE OFFICER, YOU NEED TO HANDLE AN ELOPEMENT") ; String A="I GOT THIS"; String B="HELP ME BATMAN"; String C="GOOD LUCK OUT THERE"; int criminal; if(criminal<5) System.out.println (A); else if(criminal>5 && criminal<10) System.out.println (B); else System.out.println (C); } }
4 Answers
+ 3
https://code.sololearn.com/c7qdPl3NHvo7/?ref=app
this may help you
+ 1
you ask for help when you have 5 to 10 opponents. so the else if statement should be:
else if (criminal>=5 && criminal <=10)
+ 1
import java.util.Scanner ;
public class Program
{
public static void main(String[] args) {
Scanner sc=new
Scanner (System.in);
int x=sc.nextInt();
if(x<5){
System.out.println ("I got this!");}
else if(x>=5){if(x<=10){
System.out.println ("Help me Batman");}
else {
System.out.println ("Good Luck out there!");
}
}
}
}
0
import java.util.Scanner;
public class Program
{
public static void main(String [] args)
{
Scanner sc = new Scanner ( System.in);
String A="I got this!";
String B="Help Me Batman";
String C="Good Luck Out There!";
int criminal;
criminal = sc.nextInt();
if(criminal<5)
System.out.println (A);
else if(criminal>=5 && criminal<10)
System.out.println (B);
else
System.out.println (C);
}
}
This code is failing for 5 asa input. Why??