java - Using while loops to validate input -
I want to enter the user "y" "y" "n" or "n" As a result the code asks the user to enter Y or N when they enter the correct input, which I was expecting! Input.equalscaseignore (Input) in front of
import java.util.Scanner; Class inputwid {public static zero main (string [] args) {string input; Scanner Keyboard = New Scanner (System.in); System.out.println ("Please enter Wi or N"); Input = keyboard.nextLine (); While (! Input.equalsIgnoreCase ("Y") ||! Input.equalsIgnoreCase ("N")} {System.out.println ("Please enter Y or N"); Input = keyboard.nextLine (); } Keyboard.close (); }}
This is your or
status, you must Change it to and
(While! Input.exile ignoror season ("Y") & amp;! Input.Ageles Ignore Seas ("N")) < Just reading aloud will help to understand the logic: Whenever the input is not equal (ignore the case) "Y" and Input does not equal (ignore case) "n"
Comments
Post a Comment