Advertisement
CR7CR7

playCard

Nov 9th, 2022
751
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.02 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class CheckForPlayCard {
  3.     public static void main(String[] args) {
  4.         /*
  5.         Classical play cards use the following signs to designate the card face: 2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, K and A.
  6.         Write a program that enters a string and prints “yes” if it is a valid card sign or “no” otherwise.
  7.          */
  8.         Scanner scan =new Scanner(System.in);
  9.         String playCard =scan.nextLine();
  10.         switch (playCard) {
  11.                 case "2":
  12.                 case "3":
  13.                 case "4":
  14.                 case "5":
  15.                 case "6":
  16.                 case "7":
  17.                 case "8":
  18.                 case "9":
  19.                 case "10":
  20.                 case "J":
  21.                 case "Q":
  22.                 case "K":
  23.                 case "A":
  24.                     System.out.println("yes");
  25.                     break;
  26.                 default:
  27.                     System.out.println("no");
  28.                     break;
  29.         }
  30.     }
  31. }
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement