Dear Java users,
I don't have computer science background but I have knowledge about programs and have been using the MatLAB for on and off project. I have knowledge about the loops and conditions basics but not familiar with the syntax errors in java.
Trying to write a simple program using if, else if condition and it gives error on line 18 please check below:
I will appreciate your help!
import java.util.Scanner;
public class PracticeIfStatement {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
try {
System.out.println("Enter your age:");
int age = input.nextInt();
if (age > 0 && age <=10 );{
System.out.println("Your age is from 0 to 10");
}
//18th line (error syntax error on token)
else if (age >=11 && age <=20){
System.out.println("your age is from 11 to 20");
}
else if ( age >=20 && age <=30) {
System.out.println("your age is from 20 to 30");
}
else {
System.out.println("Your are above 30");
}
}
catch(Exception e) {
System.out.println("You can not enter Zero");
}
}
}