+ 1
Can you check what is the error? (Java)
5 ответов
+ 1
Rabeeh , look at the corrected code. Hope it helps you 🐱
https://code.sololearn.com/cB5Cf2oFVQ1W/?ref=app
+ 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");
}
}
}
+ 1
The problem was the code identation copy this code
+ 1
In java we can write if clause without { so attention with your code identation
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");}
}
}