0
Pls help me..
idk what s wrong but switch case is wrong.. wtf i go8ng on.. i did everything good... code dowb here class sperm{ public static void main(String [ ] arts){ int ea = 3; int ba = 500; int ca = 489; Switch(ea); { case 1: System.out.println("You are not smart"); break; case 2: System.out.println("You not smart but not and dumb"); break; case 3: if(ba > 499 || ca < 489);{ System.out.println("U smart"); } break; case 4: if(ba < 499 || ca > 489);{ System.out.println("SMART 500 IQ"); } } } }
2 Antworten
+ 1
az1o In Java, semicolon (;) is use to break the statement so if you write semicolon after if block then program will skip there and next step will not work.
So in your code you have wrongly uses the semicolon.
Also you need to know that Java is case sensitive. So you can't write switch to Switch.
Corrected:
class sperm{
public static void main(String [ ] arts){
int ea = 3;
int ba = 500;
int ca = 489;
switch(ea) {
case 1:
System.out.println("You are not smart");
break;
case 2:
System.out.println("You not smart but not and dumb");
break;
case 3:
if(ba > 499 || ca < 489) {
System.out.println("U smart");
}
break;
case 4:
if(ba < 499 || ca > 489) {
System.out.println("SMART 500 IQ");
}
}
}
}