Question: Why doesn't my code match the output in the samples? ( You should include your name and section number as part of the comments

Why doesn't my code match the output in the samples? "
(You should include your name and section number as part of the comments for your
project assignment!!!)
Testing Cases
First, you should test running your program a few times with each the following "hard-
coded" initial pile sizes: 25,31,250 and 255. Under each initial pile size, try to generate
the different cases: (1) Computer plays first; (2) The user plays first; (3) The computer
player wins the game; (4) The user wins the game.
Second, you should test running your program a few times with randomly generated
initial pile size, try to generate the different cases as described above.
The following are some sample outputs when you run your program:
(Note that the blue part represents the user input, and "" represents the enter/return key
from the user input.)
Sample output 1:
Welcome to the game of Nim (for two players)
Please input your name: Yi Pike
The game of Nim *
Players alternate taking at least one but at *
most half of the marbles in the pile. *
The player who takes the last marble loses. *
It is written by Yi Pike *
I hope you beat the computer:)*
No matter what, have a great day! *
Yi Pike will play first.
Then followed by the Computer.
There are 25 marbles in the pile.
\Phi
\Phi
\Phi
\Phi
\Phi
\Phi
\Phi
\Phi
\Phi
\Phi
\Phi
\Phi
\Phi
\Phi
\Phi
\Phi
\Phi
\Phi
\PhiIt is Yi Pike's turn:
Your turn to play .. you may take 1 to 12 marbles.You
take: I will move 10 marbles
Invalid! Please try again...
Your turn to play ... you may take 1 to 12 marbles.You
take: ten marbles
Invalid! Please try again...
Your turn to play ... you may take 1 to 12 marbles.You
take: 10.75 marbles ok?
You will take 10 marbles.
There are 15 marbles in the pile. (You should include your name and section number as part of the comements for your
projoct assignment!!!)
Testing Cases
First, you should tast ruming your program a few times with each the following "hard-
coded" initial pile sizses: 25,31,250 and 255. Uvder asch initial pile sizes, try to genesate
the diffareat cases: (1) Comprater plays first, (2) The user plays firnt; (3) The computar
player wins the grome; (4) The nser wins the game.
Second you sbould tast ranning your program a fow times with randomly genarated
initial piles size, try to generate the different cases as described above.
The following are some sample outputs when you ran your program:
(Note that the blue part represents the mer input, and "+" repreveats the anter/retarn key
from the mer input)
Sample output 1:
Welcome to the game of Nim (for two players)
Please input your name: Yi Pike
the game of Ni 1
Players alternate taking at least one but at
most half of the marbles in the pile.
The player who takes the last marble loses.
It is written by Y1 pike
I hope you beat the conputer:
No matter what, have a great day
Yi Pike will play first.
Then followed by the Computer.
There are 25 marbles in the pile.
5
85
55
8
It is Y1 Pike's turn:
Your turn to play ... you may take 1 to 12 marbles.You
take: I will nove 10 marblest
Invalid Please try again..
Your turn to play ... you may take 1 to 12 marbles. You
take: ten marbles
Your tul Please try again..
Your turn to play ... you may take 1 to 12 marbles.You
take: 10.75 marbles ok?+
There are 15 marbles in the pile.
It is Conputer's turn
The computer takes 2 marbles.
There are 13 marbles in the pile.
It is Y1 Pike's turn:
Your turn to play ... you may take 1 to 6 marbles.It is ri Pike"s turn:
Your turn to play ... you may take 1 to 6 marbles.
You take: seven I guesst
Invalidl Please try again..
Your turn to play ... you may take 1 to 6 marbles.
Ooops, you picked too many or not enough.
please try again...
Your turn to play.. you may take 1 to 6 marbles.
You take: 6 is my choicet
You w1ll take 6 marbles.
There are 7 marbles in the pile.
It is Computer's turn
The computer takes 1 marbles.
There are 6 marbles in the pile.
It is Yi Pike's turn:
Your turn to play.. you may take 1 to 3 marbles.
You take: 3.5 marbles ok?4
You will take 3 marbles.
There are 3 marbles in the pile.
@
It is Conputer's turn:
The computer takes 1 marbles.
There are 2 marbles in the pile.
Why doesn't my code match the output in the

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