Advertisement
Guest User

Print Deck of Cards_Solution_2

a guest
Sep 27th, 2022
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.38 KB | None | 0 0
  1. package com.company.tests;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Main {
  6.  
  7.     private static final String[] inputs = {"g", "j", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A"};
  8.  
  9.     public static void main(String[] args) {
  10.  
  11.         Scanner scanner = new Scanner(System.in);
  12.         String inputStr = scanner.nextLine();
  13.         int times = Integer.parseInt(inputStr);
  14.  
  15. /*        
  16.         char spade = '\u2660';
  17.         char heart = '\u2661';
  18.         char diamond = '\u2662';
  19.         char club = '\u2663';
  20. */
  21.  
  22.         if (times > 1 && times < 15) {
  23.             for (int i = 0; i < inputs.length; i++) {
  24.                 if (inputStr.equals(inputs[i])) {
  25.                     for (int j = i; j < inputs.length; j++) {
  26.                         System.out.printf("%s of spades, %s of clubs, %s of hearts, %s of diamonds", inputs[j], inputs[j], inputs[j], inputs[j]);
  27.                         System.out.println();
  28.                     }
  29.                 }
  30.             }
  31.                     if (times > 10){
  32.                         for (int j = times; j < inputs.length; j++) {
  33.                             System.out.printf("%s of spades, %s of clubs, %s of hearts, %s of diamonds", inputs[j], inputs[j], inputs[j], inputs[j]);
  34.                             System.out.println();
  35.                         }
  36.                     }
  37.                 }
  38.             }
  39.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement