Question: PLEASE ANSWER WITH JAVA CODES ## The goal The goal of this assignment is to practice logic and loops in Java. ## Instructions Complete this

PLEASE ANSWER WITH JAVA CODES

## The goal

The goal of this assignment is to practice logic and loops in Java.

## Instructions

Complete this project, such that it allows a user to play a simplified version of the game of Blackjack against a virtual dealer.

In our simplified version of Blackjack, the play unfolds as follows:

1. Two cards are dealt and displayed to the user.

1. Two cards are dealt to the dealer, but these are secret and not displayed to the user.

1. The user is prompted whether they would like an additional card (a "hit"). This question is repeated and the user may accept as many additional cards as they would like, until they respond with the words "stand", "stop", or "pass". If the value of the cards exceeds 21 at any point during this process of accepting cards, the user has "busted" and lost, and the game ends.

1. Assuming the user has not busted, once the user stops accepting new cards, the robotic dealer decides whether to accept as many additional cards as it wants. You can have the robot dealer do this at random if you like, or you can develop an artificial intelligence algorithm of your choosing. If the robot dealer's cards exceed 21 points during this process, the dealer has busted and lost, and the user wins.

1. Unless one of the players has busted, at the end of the game, if the user's cards are higher in total value than the dealer's cards, the user wins. Otherwise, the dealer wins.

1. Regardless of how the game ends, whether by a bust or by a win, the program must show the user what cards they had and what cards the dealer had at the end of the game and announce the result of the game (either there is a winner, a tie, or one of the players has bust.)

### Additional notes:

- Do not worry about drawing the same card twice. Draw cards at random.

- All "cards" are simply integer values from 2 thru 11.

- These rules are slightly different from how Blackjack is played in casinos. Follow our version's rules.

Additional requirements are written as comments within the given source code files.

### Sample output

The following are sample outputs from running the program with various outcomes. User responses are indicated on the same line as the program output for ease-of-reading only - in all cases user input will actually appear on a separate line.

Your program's output should exactly match these patterns.

#### Sample output: user stands, dealer stands

```

Welcome to Blackjack!

Your cards are: 2 and 4

Would you like to hit or stand? stand

The dealer stands.

The dealer's cards are: 8, 7

Dealer wins!

```

#### Sample output: dealer wins:

```

Welcome to Blackjack!

Your cards are: 3 and 7

Would you like to hit or stand? hit

Your cards are: 3, 7, and 4

Would you like to hit or stand? hit

Your cards are: 3, 7, 4, and 2

Would you like to hit or stand? stand

The dealer hits.

The dealer hits.

The dealer hits.

Your cards are: 3, 7, 4, and 2

The dealer's cards are: 8, 3, 4, 3, 3

Dealer wins!

```

#### Sample output: user wins:

```

Welcome to Blackjack!

Your cards are: 8 and 2

Would you like to hit or stand? hit

Your cards are: 8, 2, and 8

Would you like to hit or stand? stand

The dealer hits.

The dealer stands.

Your cards are: 8, 2, and 8

The dealer's cards are: 3, 3, and 7

You win!

```

#### Sample output: tie:

```

Welcome to Blackjack!

Your cards are: 5 and 6

Would you like to hit or stand? hit

Your cards are: 5, 6, and 3

Would you like to hit or stand? stand

The dealer hits.

The dealer hits.

The dealer stands.

Your cards are: 5, 6, and 3

The dealer's cards are: 2, 6, 2, and 4

Tie!

```

#### Sample output: dealer busts:

```

Welcome to Blackjack!

Your cards are: 5 and 6

Would you like to hit or stand? hit

Your cards are: 5, 6, and 3

Would you like to hit or stand? stand

The dealer hits.

The dealer stands.

Your cards are: 5, 6, and 3

The dealer's cards are: 8, 8, and 10

The dealer has bust!

You win!

```

#### Sample output: user busts:

```

Welcome to Blackjack!

Your cards are: 5 and 6

Would you like to hit or stand? hit

Your cards are: 5, 6, and 3

Would you like to hit or stand? hit

Your cards are: 5, 6, 3, and 10

You have bust!

Dealer wins!

```

Note that in our version of Blackjack, if the user busts, this happens before the dealer has received any cards.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!