I'm writing a simple user input
package caleb.fournier;
import java.util.Scanner;
//This line above must be used if you're using user input
public class Caleb
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
int age;
System.out.println("How old are you?");
age=in.nextInt();
if (age >= 21);
System.out.println("You are old enough to drink");
else
System.out.println("You are not old enough to drink");
}
}
And getting this error
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
Syntax error on token "else", assert expected
then cannot be resolved to a variable
at caleb.fournier.Caleb.main(Caleb.java:15)
PLEASE HELP ME.
package caleb.fournier;
import java.util.Scanner;
//This line above must be used if you're using user input
public class Caleb
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
int age;
System.out.println("How old are you?");
age=in.nextInt();
if (age >= 21);
System.out.println("You are old enough to drink");
else
System.out.println("You are not old enough to drink");
}
}
And getting this error
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
Syntax error on token "else", assert expected
then cannot be resolved to a variable
at caleb.fournier.Caleb.main(Caleb.java:15)
PLEASE HELP ME.
