Write a program that scores a blackjack hand. In blackjack, a player receives from two to...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a program that scores a blackjack hand. In blackjack, a player receives from two to five cards. The cards 2 through 10 are scored as 2 through 10 points each. The face cards (jack, queen, and king) are scored as 10 points. The goal is to come as close to a score of 21 as possible without going over 21. Hence, any score over 21 is called "busted". The ace can count as either 1 or 11, whichever is better for the user. The user is asked how many cards they have, and the user responds with an integer 2, 3, 4, or 5. The user is then asked for the card values. Card values are 2 through 10, jack, queen, king, and ace. A good way to handle input is to use the type char. Input the values 2 through 9 as the characters '2' through '9'. Input the values 10, jack, queen, king, and ace as the characters 't', 'q', 'k', and 'a'. Allow upper and lowercase letters. After reading in the values, the program should convert them from character values to numeric card scores, taking special care for aces. The output is either [2.21] or the word busted. Your program should include a loop that lets the user repeat this calculation until the user says they are done. You may have multiple long multiway branches. Write a program that scores a blackjack hand. In blackjack, a player receives from two to five cards. The cards 2 through 10 are scored as 2 through 10 points each. The face cards (jack, queen, and king) are scored as 10 points. The goal is to come as close to a score of 21 as possible without going over 21. Hence, any score over 21 is called "busted". The ace can count as either 1 or 11, whichever is better for the user. The user is asked how many cards they have, and the user responds with an integer 2, 3, 4, or 5. The user is then asked for the card values. Card values are 2 through 10, jack, queen, king, and ace. A good way to handle input is to use the type char. Input the values 2 through 9 as the characters '2' through '9'. Input the values 10, jack, queen, king, and ace as the characters 't', 'q', 'k', and 'a'. Allow upper and lowercase letters. After reading in the values, the program should convert them from character values to numeric card scores, taking special care for aces. The output is either [2.21] or the word busted. Your program should include a loop that lets the user repeat this calculation until the user says they are done. You may have multiple long multiway branches.
Expert Answer:
Related Book For
A First Course In Mathematical Modeling
ISBN: 9781285050904
5th Edition
Authors: Frank R. Giordano, William P. Fox, Steven B. Horton
Posted Date:
Students also viewed these programming questions
-
Hi Can you please advise if my answers are correct? Question 1: ABL shares are currently trading at a price of $27, while HHT shares are trading at a price of $10.05. The risk-free rate is 1.27% per...
-
Microkernel operating systems aim to address perceived modularity and reliability issues in traditional "monolithic" operating systems. (i) Describe the typical architecture of a microkernel...
-
Construct and perform a Monte Carlo simulation of blackjack (also called twenty-one). The rules of blackjack are as follows: Most casinos use six or eight decks of cards when playing this game to...
-
Required A. Calculate Mr. Worthy's minimum employment income for the current year. B. Assume Mr. Worthy had only $4,000 in commission income in addition to his $65,000 salary. Calculate Mr. Worthy's...
-
The random vector Y = [Y1 Y2]ʹ has covariance matrix where γ is a constant. In terms of γ, what is the correlation coefficient ÏY1, Y2 of Y1 and Y2? For what...
-
Assume there are two "states of the world": in the good state, a risky asset yields a high return, whereas in the bad state, it yields a loss; the safe asset yields a zero return in both. Let Cg...
-
Decker Corporation experienced a loss in 2020. Additional information for Decker Corporation follows. There were no temporary differences from 2018 to 2020 other than any related to a net operating...
-
Skaros Stairs Co. of Moore designs and builds factory-made premium wooden stairways for homes. The manufactured stairway components (spindles, risers, hangers, hand rails) permit installation of...
-
hello I need 1040 pg 2. schedule 1 & 3 forms did Reba Dixon is a fifth grade school teacher who earned a salary of $38,000 in 2019. She is 45 years old has been divorced for four years. She rece...
-
Janet, Karen, and Lisa are equal general partners in JKL Partnership. In Year 1 the partnership made liquidating distributions to each of the partners. Information about the assets distributed and...
-
n Question 5 Which diagram has the circle of illumination in the correct place? (star shape = sun, north & south pole shown, C = line that could be circle of illumination) a. O **Q*QQ* A B 2.5 pts D
-
Peter Inc. of Cebu Ltd. has decided to institute a pilot activity-based costing project in its five-person purchasing department. Annual departmental costs are P473,500. Because finding the best...
-
What is the holding period yield for an investor who pays $ 1 , 2 5 0 for a three - year bond with a $ 1 , 0 0 0 face value and a 6 % coupon and sells the bond two years later for $ 1 , 3 2 0 ?
-
Assume the rate of interest is 8 % . How much would you need to set aside to provide $ 1 billion a year spread evenly over 2 0 years.
-
The Ste. Marie Division of Pacific Media Corporation just started operations. It purchased depreciable assets costing $50 million and having a four-year expected life, after which the assets can be...
-
Find the monthly payment for the loan. Purchase Price $3600 Down Payment $400 The monthly payment is $ (Round to the nearest cent as needed.) Finance Charge $220 39 of 40 # of Monthly Payments 60 ***
-
6. could you provide a non-finance example on regression? In particular, detail the process on how you conduct the regression and determine the significance of alpha and beta. 11. According to your...
-
Prove the following D,(cos x) = - sin x (Hint: Apply the identity cos(A + B) = cos A cos B sin A sin B)
-
Explain why the procedure for using a maximum flow algorithm to find the size of a maximum matching in a bipartite graph works. Can it be used to find a maximum matching (as opposed to the size of...
-
Consider a construction firm that is deciding to specialize in building high schools or elementary schools or a combination of both over the long haul. The construction company must submit a bid...
-
The following data represent (hypothetical) energy consumption normalized to the year 1900. Plot the data. Test the model Q= ae bx by plotting the transformed data. Estimate the parameters of the...
-
A small town has 450 registered voters. In the primaries, 54 voted. What percentage of registered voters in that town voted in the primaries?
-
1. What is the total if \(25 \%\) of the total is 30 ? 2. What is the total if \(45 \%\) of the total is 360 ?
-
1. Determine \(25 \%\) of 1,200 . 2. Determine \(53 \%\) of 1,588 .
Study smarter with the SolutionInn App