Answered step by step
Verified Expert Solution
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.
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started