Write a Java program (TicTacToe.java) for playing tic-tac-toe. You may assume that two human players are playing against each other. Your program should display an updated board before every turn, prompt the user to enter the row and column in which to play, and display "X wins!", "O wins!", or "Tie!" at the end of the game.
Write a Java program (TicTacToe.java) for playing tic-tac-toe. You may assume that two human players are playing against each other. Your program should display an updated board before every turn, prompt the user to enter the row and column in which to play, and display "X wins!", "O wins!", or "Tie!" at the end of the game.
Here is a sample run of a correct program (user input indicated by orange text):
Let's play Tic-Tac-Toe!
- - -
- - -
- - -
Enter a row and column (1, 2, 3) for player X: 2 2
- - -
- X -
- - -
Enter a row and column (1, 2, 3) for player O: 2 3
- - -
- X O
- - -
Enter a row and column (1, 2, 3) for player X: 1 1
X - -
- X O
- - -
Enter a row and column (1, 2, 3) for player O: 1 3
X - O
- X O
- - -
Enter a row and column (1, 2, 3) for player X: 3 3
X - O
- X O
- - X
X wins!

Trending now
This is a popular solution!
Step by step
Solved in 3 steps









