D. Final Algorithm, Flowchart, or Pseudocode

Over-Under Flow Chart

Hangman Flow Chart

 

Blackjack  Algorithm/Pseudo-Code

Assumptions/Givens:

1. The player knows the rules of blackjack.

2. A function exists to draw cards.

3. Functions exist to calculate the player and dealer scores.

4. Functions exist to display the player and dealer hands.

Algorithm/Pseudo-Code:

1. Draw two cards each for the dealer and the player and store them in separate matrices

2. Set both the player and dealer score to zero

3. Display both the dealer and player’s hands

4. Calculate the initial score of both the player and dealer by looping through each card in each hand with the calculate score functions and keep track of each score in separate variables.

5. Check if the dealer’s score is at or below 16. If so, draw a card, add it to their hand,  recalculate their score, and display the card with the rest of their cards until the condition is false.

6. Ask the player if they would like to “hit” or “stand”. If the player chooses “hit”, a card is drawn and added to their hand, their score is recalculated, and the card is displayed with the rest of their cards. The player is then prompted again if they would like to hit or stand. If the player chooses “stand” the game ends.

7. Display the player and dealer scores and determine who the winner is or if it was a draw and output this information.

8. Ask the player if they would like to play again, and if the player says “yes” repeat steps 1-8. If the player says “no” the game terminates.