Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please do it C++ at a very beginner level. Program: Game of NIM NIM is an ancient and fairly simple game. NIM is a mathematical

Please do it C++ at a very beginner level.

image text in transcribed

image text in transcribed

Program: Game of NIM NIM is an ancient and fairly simple game. NIM is a mathematical game of strategy in which two players take turns removing objects from a heap. On each turn, a player must remove 1,2 , or 3 of the objects. The player forced to remove the last object loses. The purpose of this assignment is to reinforce concepts presented earlier and introduces More sophisticated if-else statements. Loops: while and do while Random numbers. Be sure to adequately document your program. The heap starts with 23 objects. Write the game for a player to compete against the computer. That is one player is human and the other is the computer. The human will go first. Then the computer and human alternate turns. When it is the human's turn, Print out the player's name and ask for the move. The move must be between 1 and 3 and cannot be more than what is in the heap. When it is the computer's turn, generate a pseudo random number between 1 and 3 . Make sure it is less than the number of objects in the heap. When the number of objects reaches zero, announce the winner. Random numbers: 1. Necessary includes 2. Seed the random number generator once at the beginning of the program: / * initialize random seed: */ srand (time (NULL)); 3. Generate a random number between 1 and 3 / generate secret number between 1 and 3:/ iMove =rand() \& 3+1; main.cpp Load default template... 123456789#includeiostreamusingnamespacestd;intmain(){/Typeyourcodehere.*/return0

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

Modern Database Management

Authors: Fred R. McFadden, Jeffrey Slater, Mary B. Prescott

5th Edition

0805360549, 978-0805360547

More Books

Students also viewed these Databases questions

Question

Understanding Culture?

Answered: 1 week ago

Question

Example. Evaluate 5n+7 lim 7-00 3n-5

Answered: 1 week ago

Question

Understand why empowerment is so important in many frontline jobs.

Answered: 1 week ago