Advertisement
Hey_Donny

Deck of Cards

Mar 7th, 2022
10
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class PrintDeckOfCards {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. String[] suit = {"spades", "clubs", "hearts", "diamonds"};
  8. String[] cards = {"2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A"};
  9. int n = scanner.nextInt();
  10. int counter = 0;
  11.  
  12. for (int i = 0; i <= 14; i++) {
  13. for (int j = 0; j < 4; j++) {
  14. if (i > n - 2)
  15. continue;
  16. if (j < 3)
  17. System.out.printf("%s of %s, ", cards[i], suit[j]);
  18. counter++;
  19. if (counter % 4 == 0) {
  20. System.out.printf("%s of %s", cards[i], suit[j]);
  21. System.out.println();
  22. break;
  23. }
  24. }
  25. }
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement