Reveal a card in a short deck.
Cutting the deck is a common way to resolve draws in playing card games. One player takes any number of cards (usually approximately half) from a face down full deck and then reveals the card on the bottom of their pile. The second player then takes any card from those remaining in the deck and reveals their card.
Higher numbers beat lower numbers regardless of suit. J is 11, Q is 12, K is 13 and A is 14. The alphabetical order of the suit resolves draws. Clubs (C) is lowest followed by diamonds (D), hearts (H) and spades (S) is the highest.
In a short deck the lowest number is a 6. Therefore the 6C (the six of clubs) is the lowest card and AS (the ace of spades) is the highest card.
Write a program that asks the user to pick one of the first thirty-five cards in the deck. All the previous cards are discarded. The computer then picks one of the remaining cards. Whoever has the highest card wins. The result is output to the user.
Use this boilerplate code as a starting point:
Remember to add a comment before a subprogram, selection or iteration statement to explain its purpose.
Hint: Modulus 9 will tell you the value of the card because there are 9 cards in each suit. In the case of draws you can look up the index of the card drawn in the cards list to know a card's relative value.
What number card do you want to draw? 0-34 :20
You reveal the 8H
The CPU reveals the AS
CPU wins.
What number card do you want to draw? 0-34 :13
You reveal the 10D
The CPU reveals the 9S
You win!
What number card do you want to draw? 0-34 :18
You reveal the 6H
The CPU reveals the 6S
CPU wins.
Use these resources as a reference to help you meet the success criteria.
Run the program several times to check that your program has met the success criteria.
Check that you have: