Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Create a class Deck that represents a deck of cards. Your class should have the following methods:
constructor Creates a new deck of 52 cards in a standard order.
shuffle Randomizes the order of the cards.
dealCard Returns a single card from the top of the deck and removes the card from the deck.
cardsLeft Returns the number of cards remaining in the deck.
Test your program by having it deal out a sequence of n cards from a shuffled deck where n is a user input. You could also use your deck object to implement a Blackjack simulation where the pool of cards is finite. See Programming Exercises 8 and 9 in Chapter 9.

Exercises 8:

Blackjack (twenty-one) is a casino game played with cards. The goal of the game is to draw cards that total as close to 21 points as possible without going over. All face cards count as 10 points, aces count as 1 or 11, and all other cards count their numeric value.

The game is played against a dealer. The player tries to get closer to 21 (without going over) than the dealer. If the dealer busts (goes over 21), the player automatically wins (provided the player had not already busted). The dealer must always take cards according to a fixed set of rules. The dealer takes cards until he or she achieves a total of at least 17. If the dealer's hand contains an ace, it will be counted as 11 when that results in a total between 17 and 21 inclusive; otherwise, the ace is counted as 1.

Write a program that simulates multiple games of blackjack and estimates the probability that the dealer will bust. Hints: treat the deck of cards as infinite (casinos use a "shoe" containing many decks). You do not need to keep track of the cards in the hand, just the total so far (treating an ace as 1) and a bool variable hasAce that tells whether or not the hand contains an ace. A hand containing an ace should have 10 points added to the total exactly when doing so would produce a stopping total (something between 17 and 21 inclusive).

Exercises 9:

A blackjack dealer always starts with one card showing. It would be useful for a player to know the dealer's bust probability (see previous problem) for each possible starting value. Write a simulation program that runs multiple hands of blackjack for each possible starting value (ace-10) and estimates the probability that the dealer busts for each starting value.

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M92059687

Have any Question?


Related Questions in Computer Engineering

What is the net present value of a project with a discount

What is the Net Present Value of a project with a discount rate of 12%p.a. whose Net Cash Flows are forecast to be: Year 0: $15,000 outflow Year 1: $2,000 inflow Year 2: $3,000 inflow Year 3: $5000 inflow Year 4 $10,000 ...

Question individual project - submit to the unit 3 ip

Question: Individual Project - Submit to the Unit 3 IP Area This part of the assignment is FOR GRADING for this week. This assignment is a document addressing security and should be submitted to the week's individual dro ...

The solution of this exercise please 37 creating an

The solution of this exercise please: 3.7 (Creating an Autocomplete Form) Create a simple search form using a search input element in which the user can enter a search query. Using the Firefox web browser, test the form ...

Technology certainly does play a large role in our lives

Technology certainly does play a large role in our lives and this has happened in a very short period of time. It has impacted the way we activities professionally, personally, and academically. For example, online educa ...

The system development team at the xyz company is working

The system development team at the XYZ Company is working on developing a new customer order entry system. In the process of designing the new system, the team has identified the following data entity attributes: Invento ...

Calculate the energy of one photon of blue light that has a

Calculate the energy of one photon of blue light that has a wavelenght of 425 nm and red light that has a wavelenght of 740 nm. Use E = hv and C = frequency x wavelenght(v). And determine which photon has highest energy.

Suppose the government raises taxes by 100 billion assume

Suppose the government raises taxes by $100 billion. Assume that the marginal propensity to consume out new income is 0.8(i.e if a person receives $100, he will spend $80 and save $20). Consider what happens to the follo ...

Heights of women follow a normal distribution with

Heights of women follow a normal distribution with mean μ=63.6 inches and standard deviation of σ=2.5 inches.  Suppose random samples of 10 women are chosen and their mean height calculated. Please calculate the mean and ...

Configuring name resolutionas the administrator of the

Configuring Name Resolution As the administrator of the Contoso Corporation, you manage an internal website that is often used by most users with the company. You try to connect to an internal website but cannot open the ...

A 200g sample of acetylsalicylic acid better known

A 2.00g sample of acetylsalicylic acid, better known asaspirin, is dissolved in 100mL of water and titrated with 0.200mol/L NaOH(aq) to the end point. The volume of base required is 55.5mL. Calculate the molar mass of ac ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As