Every time I write Character.isLetter(4))
it highlights isLetter
...
Please help. I am trying to make a program that you have to tell the age to continue, but if you enter letters, an error pops up.
this is my full code, and it doesn't work.
import java.util.Scanner;
public class Prmtrs1
{
public static int user_age2;
public static String user_age;
public static void main(String args[]) {
Scanner input = new Scanner(System.in);
Prmtrs2 POblect = new Prmtrs2 ();
System.out.println("Type in your name in here! ");
String name = input.nextLine();
POblect.Hello(name);
System.out.println("");
System.out.println("Enter your age, " + name);
user_age = input.nextLine();
while(user_age.matches("\\d+")) {
System.out.println("enter numbers from 0 to 9");
user_age = input.nextLine();
}
System.out.println("Your age is " + user_age + ", " + name);
int user_age2 = Integer.parseInt(user_age);
if(user_age2 >= 18)
{
System.out.println("So...");
System.out.println("You are eligible to Vote, " + name + "!");
}
else{
System.out.println("So...");
System.out.println("You are not eligible to vote, " + name + "!");
}
}
}