Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

SIDE NOTE: PLEASE USE C++ ar potr Programming Exercise The game of 23 is a two-player game that begins with a pile of 23 toothpicks.

image text in transcribed

SIDE NOTE: PLEASE USE C++

ar potr Programming Exercise The game of 23 is a two-player game that begins with a pile of 23 toothpicks. Players take turns, withdrawing either 1, 2 or 3 toothpicks at a time. The player to withdraw the last toothpicks loses the game. Write a human vs computer program that plays "23". The human should always move first. When it is the computer's turn, it should play according to the following rules: Hare are sovesanpleouput screers to asvane the expetted bel-avor of yout proga If there are more than 4 toothpicks left, then the computer should withdraw (4 toothpicks where X is the number of toothpicks the human withdrew on the previous turn. If there are 2 to 4 toothpicks left, then the computer should withdraw enough toothpicks to leave 1. If there is 1 toothpick left, then the computer has to take it and loses. . - X) the lest D ulaer vi . . When the human player enters the number of toothpicks to withdraw, the program should perform input validation. Make sure that the entered number is between 1 and 3 and that the player is not trying to withdraw more toothpicks than exist in the pile. Your C++program must prompt the human user for his/her name and use the name in all messages to the human player (See figures 5 to 7 for samples). As usual you should have a banner, a welcome message and a closing message. Be sure to display the number of toothpicks the computer removes each turn as well as the remaining toothpicks after each ::.?.2?ir. ,. m.mt, " 3m@

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

Data Analysis Using SQL And Excel

Authors: Gordon S Linoff

2nd Edition

111902143X, 9781119021438

More Books

Students also viewed these Databases questions