Please help. Small into codes java | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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"); } }

7th Sep 2021, 6:57 AM
Ojas Kanotra
Ojas Kanotra - avatar
4 Answers
0
Error i am receiving is ./Playground/Program.java:11: error: 'else' without 'if' else{
7th Sep 2021, 7:00 AM
Ojas Kanotra
Ojas Kanotra - avatar
+ 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"); } } }
7th Sep 2021, 7:11 AM
JaScript
JaScript - avatar
+ 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.
7th Sep 2021, 7:08 AM
ChaoticDawg
ChaoticDawg - avatar
+ 1
Thanks all it helped a lot. Given you a like 😁.
8th Sep 2021, 12:35 PM
Ojas Kanotra
Ojas Kanotra - avatar