+ 1
Please help. Small into codes java
public class Program { public static void main(String[] args) { int age = 40; if(age <= 17) { System.out.println("You are small bro");} else if(age >=35) { System.out.println("Time for heaven");} else if(age >= 18 && age <= 34); { System.out.println("Welcome bro");} else{ System.out.println("I can't help you bro"); } }
4 Antworten
0
Error i am receiving is ./Playground/Program.java:11: error: 'else' without 'if'
else{
+ 3
There are some more problems. You can see them in the changes:
public class Program {
public static void main(String[] args) {
int age = 40;
if(age <= 17) {
System.out.println("You are small bro");}
else if(age >=35) {
System.out.println("Time for heaven");}
else if(age >= 18 && age <= 34){
System.out.println("Welcome bro");}
else {
System.out.println("I can't help you bro"); }
}
}
+ 2
You have a semicolon after the closing parenthesis for your last else-if and you're missing the closing curly brace for the class.
P.S. your else statement is pointless as it is unreachable, due to all possible values covered in the if else-if blocks.
+ 1
Thanks all it helped a lot. Given you a like 😁.