Question: Write a program using C + + programming to play a game of 2 1 between a user and computer. The player tries to get

Write a program using C++ programming to play a game of 21 between a user and computer. The player tries to get as close to 21 as possible without going over. The winner is the one with a higher total but not over 21.
Example:
If a user had 18 points, a computer had 22 points => user is a winner
If a user had 15 points, a computer had 16 points => computer is a winner 21.
The program must have three files:
Specification file for the Die class - file name: Die.h
Implementation file for the Die class - file name: Die.cpp
Main or driver file to run the program - file name: DieMain.cpp
Sample output:
Let's play a game of 21!
The winner is the player with the higher total but not over 21.
-----------------------------------
Would you like to roll the dice?
Enter Y for yes or N for no: y
You have 7 points.
Computer has 6 points.
Would you like to roll the dice?
Enter Y for yes or N for no: y
You have 16 points.
Computer has 15 points.
Would you like to roll the dice?
Enter Y for yes or N for no: y
You have 18 points.
Computer has 24 points.
Would you like to roll the dice?
Enter Y for yes or N for no: n
-----------------------------------
The computer had 24 points.
You had 18 points.
Congratulations! You won!
Game Over

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 Programming Questions!