Answered step by step
Verified Expert Solution
Question
1 Approved Answer
C++ Programming Write a function named blackjack that accepts an input stream and an output stream as parameters. The input stream represents an input file
C++ Programming
Write a function named blackjack that accepts an input stream and an output stream as parameters. The input stream represents an input file containing a hand of playing cards, and returns the point value of the hand in the card game Blackjack. A card has a rank and a suit. There are 13 ranks: Ace, 2, 3. 4, 5, 6, 7, 8, 9, 10, Jack, Queen, and King. There are 4 suits: Clubs, Diamonds, Hearts, and Spades. A Blackjack hand's point value is the sum of its cards' point values. A card's point value comes from its rank; the suit is irrelevant. In this problem, cards are worth the following points: Rank Point Value 2-10 Jack (3), Queen (Q), King (K) 10 points each Ace (A) The card's rank (for example, a 7 is worth 7 points) 11 points (for this problem; simplified compared to real Blackjack) The input file contains a single hand of cards, each represented by a pair of tokens. For example 5 Diamonds Q Spades 2 Spades 3 Hearts Given the above input, your function should return 20, since the cards' point values are 510 +2+320. The input can be in mixed casing, have odd spacing between tokens, and can be split across lines. For example: 2 Hearts j SPADES a Diamonds 2 ClubS hearts Given the above input, your function should return 36, since the cards' point values are 210 +11+2+11=36 You may assume that the input stream contains at least 1 card (two tokens) of input, and that no line will contain any tokens other than valid card data. The real game of Blackjack has many other rules that you should ignore for this problem, such as the notion of qoing "bust" once you exceed a score of 21
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started