make a program that will produce a deck of fiftytwo cards t

make a program that will produce a deck of fifty-two cards , the cards are in random order every time you run the program, also create a Recursion program to determine the location of the highest value card and the lowest value card , it must be RECURSIVE only and only can have a single search function for both min and the max
(java)

Rank : Ace 2 3 4 5 6 7 8 9 10 Jack Queen King
Suit : Diamond Heart Club Spade

___________________________________

output should be :

random order 52 cards

1.

2.

3.

.....

52.

highest card is in position number :

lowest card is in postiont numer:

Solution

public class CardsDeck {

   private static String[] SUITS = {\"Diamonds\", \"Hearts\", \"Clubs\", \"Spades\"};
   private static String[] RANKS = {\"Ace\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\", \"10\", \"Jack\", \"Queen\", \"King\"};
   public CardsDeck() {
       // TODO Auto-generated constructor stub
   }

   public static void main(String[] args) {
      
       String[] deck = new String[RANKS.length * SUITS.length];
       for (int i = 0; i < RANKS.length; i++){
       for (int j = 0; j < SUITS.length; j++){
       deck[SUITS.length*i + j] = RANKS[i] + \" of \" + SUITS[j];
       }
       }
       int n = deck.length;
       for (int i = 0; i < n; i++) {
       int r = (int) (Math.random() * n);
       String temp = deck[r];
       deck[r] = deck[i];
       deck[i] = temp;
       }
       int index = 1;
       for (int i = 0; i < RANKS.length; i++){
       for (int j = 0; j < SUITS.length; j++){
           System.out.println(index++ +\". \"+deck[SUITS.length*i + j]);
       }
       }
       findMinAndMax(deck,0,false,false);
   }
   public static void findMinAndMax(String[] deck, int index, boolean minFound, boolean maxFound){
      
       if(deck[index].equalsIgnoreCase(\"King of Spades\")){
           System.out.println(\"highest card is in position number: \"+(index+1));
           maxFound = true;
       }
       else if(deck[index].equalsIgnoreCase(\"Ace of Diamonds\")){
           System.out.println(\"highest card is in position number: \"+(index+1));
           minFound = true;
       }
       if(minFound && maxFound){
           return;
       }
       else{
           findMinAndMax(deck,index+1,minFound,maxFound);
       }
   }

}

Output1:

1. 7 of Diamonds
2. 10 of Spades
3. 6 of Diamonds
4. 4 of Hearts
5. 10 of Clubs
6. 3 of Hearts
7. 9 of Spades
8. 4 of Clubs
9. Ace of Hearts
10. Ace of Clubs
11. 3 of Clubs
12. 7 of Hearts
13. Ace of Diamonds
14. 2 of Hearts
15. 5 of Clubs
16. 2 of Spades
17. King of Hearts
18. 10 of Diamonds
19. 9 of Diamonds
20. 4 of Spades
21. 10 of Hearts
22. Queen of Diamonds
23. 3 of Spades
24. 5 of Hearts
25. Queen of Spades
26. 5 of Diamonds
27. 3 of Diamonds
28. 6 of Spades
29. Ace of Spades
30. 8 of Diamonds
31. Jack of Spades
32. 6 of Clubs
33. 2 of Clubs
34. 4 of Diamonds
35. Jack of Diamonds
36. 7 of Spades
37. 8 of Spades
38. 8 of Clubs
39. King of Spades
40. 6 of Hearts
41. Queen of Hearts
42. 7 of Clubs
43. 9 of Hearts
44. King of Diamonds
45. Jack of Hearts
46. 9 of Clubs
47. 8 of Hearts
48. King of Clubs
49. 2 of Diamonds
50. 5 of Spades
51. Jack of Clubs
52. Queen of Clubs
highest card is in position number: 13
highest card is in position number: 39

output2:

1. 4 of Hearts
2. Ace of Clubs
3. 4 of Diamonds
4. 3 of Diamonds
5. 6 of Spades
6. 8 of Hearts
7. 6 of Hearts
8. 2 of Spades
9. 8 of Clubs
10. 4 of Spades
11. 10 of Hearts
12. 3 of Spades
13. King of Hearts
14. 10 of Clubs
15. 5 of Hearts
16. 3 of Hearts
17. 10 of Spades
18. 9 of Spades
19. 7 of Hearts
20. Jack of Hearts
21. 5 of Spades
22. Jack of Clubs
23. 8 of Diamonds
24. 7 of Spades
25. 6 of Diamonds
26. 2 of Clubs
27. King of Clubs
28. 7 of Diamonds
29. 5 of Clubs
30. 4 of Clubs
31. Ace of Diamonds
32. Queen of Clubs
33. 9 of Clubs
34. 8 of Spades
35. 7 of Clubs
36. Jack of Diamonds
37. Queen of Spades
38. Queen of Hearts
39. 9 of Hearts
40. 3 of Clubs
41. Ace of Hearts
42. 10 of Diamonds
43. Queen of Diamonds
44. King of Spades
45. King of Diamonds
46. 9 of Diamonds
47. 2 of Diamonds
48. 2 of Hearts
49. 5 of Diamonds
50. Ace of Spades
51. 6 of Clubs
52. Jack of Spades
highest card is in position number: 31
highest card is in position number: 44

make a program that will produce a deck of fifty-two cards , the cards are in random order every time you run the program, also create a Recursion program to de
make a program that will produce a deck of fifty-two cards , the cards are in random order every time you run the program, also create a Recursion program to de
make a program that will produce a deck of fifty-two cards , the cards are in random order every time you run the program, also create a Recursion program to de
make a program that will produce a deck of fifty-two cards , the cards are in random order every time you run the program, also create a Recursion program to de

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site