Can anybody solve this small. Problem | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can anybody solve this small. Problem

class MyClass { public static void main(String[ ] args) { int x=7; if ( x < 57) { { System.out.println("work for money"); }else{ System.out.println("Ready to retire"); } }else{ if( x < 18 ) {System.out.println("Study hard and be at the top"); } } } }

22nd Aug 2018, 8:03 AM
OMKAR SAWANT
OMKAR SAWANT - avatar
3 Answers
+ 1
You can't have two else statements with just one if statement Secondly, remove 1 opening curly brace after the if statement
22nd Aug 2018, 8:05 AM
Dlite
Dlite - avatar
0
but how can I add this one statement in one program
22nd Aug 2018, 8:06 AM
OMKAR SAWANT
OMKAR SAWANT - avatar
0
in the first "else" ,change it to else if(condition){ System.out.println(" Retire"); }
22nd Aug 2018, 8:08 AM
Dlite
Dlite - avatar