Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A Game of 21 Write a program that uses the Die class that was presented in Chapter 4 to write a program that lets the

A Game of 21

Write a program that uses the Die class that was presented in Chapter 4 to write a program

that lets the user play against the computer in a variation of the popular blackjack card

game. In this variation of the game, two six-sided dice are used instead of cards. The dice

are rolled, and the player tries to beat the computers hidden total without going over 21.

Here are some suggestions for the games design:

Each round of the game is performed as an iteration of a loop that repeats as long as

the player agrees to roll the dice, and the players total does not exceed 21.

At the beginning of each round, the program will ask the user whether he or she wants

to roll the dice to accumulate points.

During each round, the program simulates the rolling of two six-sided dice. It rolls

the dice first for the computer, and then it asks the user if he or she wants to roll. (Use

the Die class that was demonstrated in Chapter 4 to simulate the dice).

The loop keeps a running total of both the computer and the users points.

The computers total should remain hidden until the loop has finished.

After the loop has finished, the computers total is revealed, and whoever the player

with the most points without going over 21 wins.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Programming The Perl DBI Database Programming With Perl

Authors: Tim Bunce, Alligator Descartes

1st Edition

1565926994, 978-1565926998

More Books

Students also viewed these Databases questions

Question

Can an experiment always be used in a prospective study? Explain.

Answered: 1 week ago

Question

What is Working Capital ? Explain its types.

Answered: 1 week ago