I have the following program below. I wanted it to only run if the input is a string, so I used hasNext() with an if statement.
Unfortunately, it will still return true when I enter numbers. I want the program to execute the else statement if a letter grade is not entered. Is there a way around this? Thank you.
import java.util.Scanner;
public class LetterGrade {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        System.out.print("Enter a letter grade: ");
        if (in.hasNext()) {
            String letterGrade = in.next();
            System.out.println(letterGrade);
        } else {
            System.out.print("Not a valid letter grade");
        }
    }
}