Reputation:
package project;
import java.util.*;
public class age {
public static void age()
{
Scanner console = new Scanner (System.in);
int age;
System.out.print("Enter age: ");
age = console.nextInt();
if (age>=18);
{
System.out.println("Legit to vote");
}else
System.out.println("Not Legit to vote");
}
}
Upvotes: 0
Views: 24
Reputation: 65793
You need to change:
if (age>=18);
to
if (age>=18)
If you had use an IDE and formatted your code properly this would have been obvious:
before
public static void age() {
Scanner console = new Scanner(System.in);
System.out.print("Enter age: ");
int age = console.nextInt();
if (age >= 18);
{
System.out.println("Legit to vote");
}else
System.out.println("Not Legit to vote");
}
after
public static void age() {
Scanner console = new Scanner(System.in);
System.out.print("Enter age: ");
int age = console.nextInt();
if (age >= 18) {
System.out.println("Legit to vote");
} else {
System.out.println("Not Legit to vote");
}
}
Upvotes: 1