Answers for "use while loop to check if user entered a letter in java"

0

how to use a while statement with char in java

private static char getHighLow(Scanner keyboard) 
{
    System.out.println("High, Low, or Sevens (H/L/S): ");
    String choiceString = keyboard.next();

    char choice = choiceString.charAt(0);

    while (choice != 'H' || choice != 'h' || choice != 'L' || choice != 'l' || choice != 'S' || choice != 's')
    {
        System.out.println("You have entered an invalid entry.");
        System.out.println("High, Low, or Sevens (H/L/S): ");
        choiceString = keyboard.next();
    }

    return choice;

}
Posted by: Guest on September-22-2020

Code answers related to "use while loop to check if user entered a letter in java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language