Advertisement
Guest User

Print Deck of Cards

a guest
Sep 25th, 2022
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.49 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Print Deck of Cards {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         String input = scanner.nextLine();
  7.         int num;
  8.  
  9.         switch (input) {
  10.             case "J":
  11.                 num = 11;
  12.                 break;
  13.             case "Q":
  14.                 num = 12;
  15.                 break;
  16.             case "K":
  17.                 num = 13;
  18.                 break;
  19.             case "A":
  20.                 num = 14;
  21.                 break;
  22.             default:
  23.                 num = Integer.parseInt(input);
  24.                 break;
  25.         }
  26.  
  27.  
  28.         for (int i = 2; i <= num; i++) {
  29.             switch (i){
  30.                 case 11:
  31.                     System.out.println("J of spades, J of clubs, J of hearts, J of diamonds");
  32.                     break;
  33.                 case 12:
  34.                     System.out.println("Q of spades, Q of clubs, Q of hearts, Q of diamonds");
  35.                     break;
  36.                 case 13:
  37.                     System.out.println("K of spades, K of clubs, K of hearts, K of diamonds");
  38.                     break;
  39.                 case 14:
  40.                     System.out.println("A of spades, A of clubs, A of hearts, A of diamonds");
  41.                     break;
  42.                 default:
  43.                     System.out.printf("%d of spades, %d of clubs, %d of hearts, %d of diamonds%n", i, i, i, i);
  44.                     break;
  45.             }
  46.         }
  47.  
  48.  
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement