Question: Write a JAVA program that will allow two users play tic-tac-toe. The program should ask for moves alternately from player 'X' and player 'O'. The

Write a JAVA program that will allow two users play tic-tac-toe. The program should ask for

moves alternately from player 'X' and player 'O'. The program displays the game

position as follows:-

1 2 3

4 5 6

7 8 9

The players enter their moves by entering the position number they wish to mark. After

each move, the program displays the changed board. A sample board configuration is

as follows:-

assuming player 'X' chose 1 followed by 2 and player 'O' chose 3 and 7.

X X O

4 5 6

O 8 9

Once all 9 positions are chosen, program should determine and print who's the winner.

Show your

report.txt

completed run of your program.

Must write the following method and the one you add.

1. Create a method

void showBoard(char board[])

- this method should display a

board on the screen. It should output each character in an array, putting a

newline every three characters.

2. Declare and use an array named board that should hold digits 'X' and 'O' . Initialize

board[ ] to character digits 1-9. Get a move until all 9 moves used. Validate that moves

are between 1-9.

3. Determine the winner.

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