Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using C++ design a program that allows two players to play a game of tic tac toe

ID: 3760151 • Letter: U

Question

Using C++ design a program that allows two players to play a game of tic

tac toe. Use a two-dimenional String array with three rows and

three columns as the game board. Each element of the array should

be initialized with an asterisk (*). The program should run a loop

that does the following:

1. Displays the contents of the board array.

2. Allows 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.

3. Allows 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.

4. Determines whether a player has won or if a tie has occurred.

If a player has won, the program should declare that player the

winner and end. If a tie has occurred, the program should say so

and end.

5. Player 1 wins when there are three Xs in a row on the game

board. Player 2 wins when there are three Os in a row on the game

board. The winning Xs or Os 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 a winner.

6. Program must be modular and have input validation

Explanation / Answer

import java.util.*; import java.io.*; import static java.lang.System.*; public class TicTacToe { private String[][]board; private static final int ROWS = 3; private static final int COLUMNS = 3; public TicTacToe() { board = new String[ROWS][COLUMNS]; for(int r=0; r
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote