+ 1

Can you check what is the error? (Java)

https://code.sololearn.com/cWdHpdU1M1v3/?ref=app

6th May 2020, 3:16 PM
Ray
Ray - avatar
5 Réponses
+ 1
Rabeeh , look at the corrected code. Hope it helps you 🐱 https://code.sololearn.com/cB5Cf2oFVQ1W/?ref=app
6th May 2020, 3:22 PM
TheWh¡teCat 🇧🇬
TheWh¡teCat 🇧🇬 - avatar
+ 1
public class Program { public static void main(String[] args) { int age = 25; if(age <= 0){ System.out.println("Error"); } else if(age <= 18){ System.out.println("Too Young"); } else if(age < 100){ System.out.println("Welcome"); } else{ System.out.println("Too Old"); } } }
6th May 2020, 3:25 PM
HEUBA BATOMEN Franck Duval
HEUBA BATOMEN Franck Duval - avatar
+ 1
The problem was the code identation copy this code
6th May 2020, 3:25 PM
HEUBA BATOMEN Franck Duval
HEUBA BATOMEN Franck Duval - avatar
+ 1
In java we can write if clause without { so attention with your code identation
6th May 2020, 3:26 PM
HEUBA BATOMEN Franck Duval
HEUBA BATOMEN Franck Duval - avatar
0
Corrected : Just remove the extra curly braces :)) public class Program { public static void main(String[] args) { int age = 25; if(age <= 0) {System.out.println("Error"); } else if(age <= 18) {System.out.println("Too Young");} else if(age < 100) {System.out.println("Welcome");} else {System.out.println("Too Old");} } }
6th May 2020, 3:23 PM
Arb Rahim Badsa
Arb Rahim Badsa - avatar