Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Your program Assignment Write a program that allows tow players to play a game of tic-tac-toe. Use a two-dimensional char array with three rows and

Your program Assignment

Write a program that allows tow players to play a game of tic-tac-toe. Use a two-dimensional char array with three rows and three columns as the game board. Each element of the array should be initialized with an astrick (*). The program should run a loop that

Displays the contents of the board array

Allow player 1 to select a location on the board for an X. The program should ask the user to enter the row and column number or a number entry that selects a column/row position

Allow player 2 to select a location on the board for an O. The program should ask the user to enter the row and column number or a number entry that selects a column/row position

Determine whether player has won, or a tie has occurred. If a player has won, the program should declare that player the winner and end that occurrence of the game. If a tie occurs, the program should say so and end that instance of the game

Once the Game has concluded, ask the user if they want to play the game again. (You may keep track of how many times each player wins).

Player 1 wins when there are three Xs in a row on the game board. The Xs can appear in a row, in a column or diagonally across the board. A tie occurs when all of the locations on the board are full, but there is no winner.

image text in transcribed

Your program Assignment Basic Steps in Creating your Program Wiite a pragram that allows tow players to play a game of tic-tac-tae. Use a two dimensional char array with three rows nd three columns as the game board. Ech element of the aroy should be Initialized with an astrick) The program should ru a loop that 1. Plan your logic before working on the project and review the syntax yau will use in the project. Think about how you want the lines of output to be displayed to the user, You will want to tell the user what the prognern doesand whal type of input yoinxpert i' or" the user (Introduction to the User). Select names of the varlables you will use . Displays the contents of the board arroy .Allow player 1 to select a location on the board for an X. The program Create oC protect In Visual Studio 2012. And have the code eirklow ope wile The pojex cexle. Display Uang Veisal Stucli te create your progrom in ond follow the instructions on creating the should ask the ues to enter the row adcolumn number or a numbe entry that selects column/row position Allow player 2 to selecta location on the boord for * n O. Ihe program . Using cout Set up Information about this progrom and what the . Ask the user to enter some Infomation requested ond save the syntax. If the cin Is used for a number, make sure you use the has won, the program should dedlare that player the winner and end that occurrence of the oome. If a tie occurs, the program should say so and end that Instance of the game Once the Came has concluded, ak the user If they want to play the player1 wins when there are three xs n row on the game board. Ihe malce It easy for the user to read the Information. Illhe ,iyi ilax1a desigfidle lines in 'ilik: 4XMHErls(//) definition at the beginning of a section of code. Nl methods and . function nl agrou hradirg dkumen 1. Run the program using Ctrl . Debuo the code, making suire all 5. Indudc the looping control structure so that the user can repeat the 6. In displaying the output correctly formatted, Remember to use the (aklalinmsre mrrx:l and the line 'Faring 5alahic! for tradability 4 5 6 entry of iriforiatiori wthout the program exiting. Ask the user if thcy want to run the progran again or cxit. anes. it's your turn! nter the nunber where you vant to nove: sotprecision), fixed and setw() to correctly format runbered oulput if

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

Students also viewed these Databases questions