I am just wanting some explanation (why) on why the following code is not working and a solution(How) to make the code run.
The goal of the program is to get a user input of a playing card, either J,Q,K,A, lower case or upper case. The program must only accept one of these values so it needs to validate the user input, displaying when its wrong and prompting till an accepted value is entered. The program then must take that user entered value and print the name of the playing card onto the console, Jack, Queen, King, Ace.
package practical_1;
import static java.lang.System.out;
import java.util.Scanner;
public class Question_4 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String Usr_Card;
out.print("Enter Card Letter Here.... ");
Usr_Card = input.next();
Usr_Card = Usr_Card.toUpperCase();
while (Usr_Card != "K" || Usr_Card != "Q" || Usr_Card != "J" || Usr_Card != "A"){
out.print("Invalid Input\nEnter Valid Card Letter Here: ");
Usr_Card = input.next();
Usr_Card = Usr_Card.toUpperCase();
}
switch (Usr_Card) {
case ("J"):
out.print("Jack");
break;
case ("Q"):
out.print("Queen");
break;
case ("K"):
out.print("King");
break;
case ("A"):
out.print("Ace");
break;
}
}
}