1) Modify the DeckOfCards class from lab 8 to use the C++ built in functions rand() and srand(). Put the class definition in a file called DeckOfCards.h and the member function definitions in a file called DeckOfCards.cpp, then create a separate file for your driver program containing the main() function, e.g., blackjack.cpp. You can compile your program using the command: g++ blackjack.cpp DeckOfCards.cpp 2) Write a program that does the following: ---Includes a function, scoreDealer() that takes an array of integers representing a Blackjack "hand" and an integer number of cards as arguments and returns the dealer's score. If the hand is a "soft hand", your function must determine the largest soft score less than 21 (one or more aces counted as 1). If that is not possible, your function should return the lowest score over 21 with all the aces in the hand counted as 1. ---Using the DeckOfCards object, deal 10,000 Blackjack hands with the "stand on soft-17 rule. Your program must call the scoreDealer() function to determine the score of each hand as it is dealt. ---For each of the 10,000 hands, count the number of occurrences of the following: dealer scores 17, 18, 19, 20, 21, natural blackjack, or busts.

This is what i have thus far. It simply outputs a set of two cards when i compile blackjack.cpp and DeckofCards.cpp together. Now how do i use the two cards to add them together and output 10,000 simulated hands of a dealer.

#include "cards.h"
#include <iostream>

using namespace std;
void displayHand(int hand[], int size);

int main()
DeckOfCards deck;
int hand[10];
for(int j=0; j<52; j++)
for (int i=0; i<2; i++)


return 0;

void displayHand(int hand[], int size)
for (int i=0; i<size; i++)
if (hand[i]==0)
cout<<"A ";
else if (hand[i]==10)
cout<<"J ";
else if (hand[i]==11)
cout<<"Q ";
else if (hand[i]==12)
cout<<"K ";
cout<<(hand[i]+1)<<' ';

Last edited on
Topic archived. No new replies allowed.