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
-
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...
-
X is the 3-dimensional Gaussian random vector with expected value μX = [4 8 6] and covariance Calculate (a) The correlation matrix, RX, (b) The PDF of the first two components of X,...
-
a. On the same axes sketches the graphs of y = (x 3) (x + 1) 2 and y = 6/x, showing clearly the points at which, the curves meet the coordinate axes. b. Hence state the number of real roots of the...
-
Repeat Example 7.3 using \(10 \mathrm{~kg} / \mathrm{h}\) of solvent in each stage. Data From Example 7.3:- The feed of Example 7.2 is extracted three times with pure chloroform at 298 K, using 8...
-
MacIntyre Fabrications, Ltd., of Aberdeen, Scotland, has recently begun a continuous improvement campaign in conjunction with a move toward Lean Production. Management has developed new performance...
-
Consider the Bertrand duopoly discussed in class. Assume each firm has constant marginal cost c = 10 and zero fixed cost. Each firm chooses a price Pi 0. The market demand is given by Q = 130 P,...
-
Whats the difference between a real resource and a virtual resource?
-
Explain what are the effects of a strong or weak dollar upon business.
-
Assuming the expectations theory is the correct theory of the term structure, calculate the interest rates in the term structure for maturities of one to four years, and plot the resulting yield...
-
A medical doctor has a patient with coronary artery disease. The decreased flow of blood to the heart is causing chest pain and shortness of breath, which has lowered the patient's utility. The...
-
In the game between Intel and AMD in the Challenge Solution, suppose that each firm earns a profit of 9 if both firms advertise. What is the new subgame perfect Nash equilibrium outcome? Show in a...
-
Prepare a full feasibility analysis, including Economic, Operational, Schedule, Legal, and Technical analyses for the system you are suggesting in problem 1. Your analysis should be no more than 30...
-
If \(g(x)=2^{3 x-1}+e^{-x} \cos x\), evaluate \(d g / d x\) when \(x=1.37\), by: a. Using the subs command. b. Conversion into a MATLAB function.
-
Just after launch from the earth. the space-shuttle orbiter is in the 37 x 137-mi ortiit shown. At the apogee point A its speed is 17 290 miihr If nothing were done to modify the orbit what would its...
-
The Place-Plus real estate development firm in Problem 24 is dissatisfied with the economists estimate of the probabilities of future interest rate movement, so it is considering having a financial...
-
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 candlestick chart is similar to a bar chart except that the candlestick chart: A. Represents upward movements in price with Xs. B. Also graphically shows the range of the periods highs and lows. C....
-
What considerations might encourage a market analyst to rely more on a top-down or bottom-up forecast of S&P 500 operating earnings?
-
Which of the following advantages listed by Ryan with respect to the earnings-based approach studied by Atkinson is most likely correct? The model A. Can be used for non-U.S. equity markets. B....
Study smarter with the SolutionInn App