Answered step by step
Verified Expert Solution
Question
1 Approved Answer
C++ programming, the output must follow the output examples given. Thanks! PROCEDURE: Part 1: Normal Mode You are required to develop a simple game using
C++ programming, the output must follow the output examples given. Thanks!
PROCEDURE: Part 1: Normal Mode You are required to develop a simple game using C++ programming where the human player competes against the computer. The game starts with 22 pebbles and a bomb inside a box. During each turn, each player is required to remove between 1 to 3 pebbles out of the box. The human player will always take the first turn. The bomb is set to detonate when there are no more pebbles in the box, effectively ending the game by killing whichever player who removed the last pebble. The computer will make a move based on the following logic. . . If there is 1 pebble remaining, the computer will have no choice but to take it. If there are 2 to 4 pebbles remaining, the computer will remove enough pebbles so that only 1 pebble remains in the box If there are more than 4 pebbles remaining, the computer will remove (4-Y) pebbles, where Y is the number of pebbles the human player removed from the box in the previous turn. Your program must ensure the player does not take more than the allocated pebbles during each turn or take more pebbles than what is left in the box. Your program must also include the use of "if", "else", and "case". Use comments to explain the flow of your code. There are 22 pebbles in the box There are 22 pebbles in the box araw 1-13 draw 1-3: 3 There are 19 pebbles in the box There are 19 pebbles in the box computer took 1 Computer took 1 There are 18 pebbles in the box araw 1-31 1 There are 18 pebbles in the box draw 1-313 There are 17 pebbles in the box Computer took ) There are 15 pebbles in the box There are 14 pebbles in the box Computer took 1 raw 1-3: 2 There are 14 pebbles in the box There are 12 pebbles in the box draw 1-3: 2 Computer took 2 There are 12 pebbles in the box There are 10 pebbles in the box Computer took 2 araw 1-3: 3 There are 10 pebbles in the box There are 8 pebbles in the box draw 1-3: 2 Computer took 2 There are 8 pebbles in the box There are 6 pebbles in the box Computer took 2 draw 1-311 There are 5 pebbles in the box There are 6 pebbles in the box draw 1-3: 3 Computer took 3 There are 2 pebbles in the box There are 3 pebbles in the box draw 1-3: 1 Computer took 2 There are 1 pebbles in the box There are 1 pebbles in the box Computer took 1 draw 1-3: 1 There are e pebbles in the box There are @ pebbles in the box BOOM! Computer lost, you are the winner! BOOM! You lost, computer is the winner! (a) (b) Fig. 1: Example of a game where the human player is the (a) winner and (b) loser There are 6 pebbles in the box draw 1-3: 5 Error, out of allowable range, enter number 1-3: B Error, out of allowable range, enter number 1-3: 3 There are 3 pebbles in the box Computer took 2 There are 1 pebbles in the box draw 1-3: 2 Error, not enough pebbles remaining, enter again: B Error, out of allowable range, enter number 1-3: 1 There are pebbles in the box BOOM! You lost, computer is the winner! Fig. 2: Example of an error message whenever the user enters invalid input Part 2: Easy Mode Modify your code to create an "Easy" mode where the computer will intentionally let the human win as quickly as possible 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