Please help me in fixing the errors in this java program.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
Please help me in fixing the errors in this java program. Then proceed in putting graphics like in the photos below Program is below // A simple program to demonstrate // Tic-Tac-Toe Game. import java.util.*; public class Main { static String[] board; static String turn; // CheckWinner method will // decide the combination // of three box given below. static String checkWinner() { for (int a = 0; a < 8; a++) { String line = null; switch (a) { case 0: line = board[0] + board[1] + board[2]; break; case 1: line = board[3] + board[4] + board[5]; break; case 2: line = board[6] + board[7] + board[8]; break; case 3: line = board[0] + board[3] + board[6]; break; case 4: line = board[1] + board[4] + board[7]; break; case 5: line = board[2] + board[5] + board[8]; break; case 6: line = board[0] + board[4] + board[8]; break; case 7: line = board[2] + board[4] + board[6]; break; } //For X winner if (line.equals("XXX")) { return "X"; } // For O winner else if (line.equals("OOO")) { return "O"; } } for (int a = 0; a < 9; a++) { if (Arrays.asList(board).contains( String.valueOf(a + 1))) { break; } else if (a == 8) { return "draw"; } } // To enter the X Or O at the exact place on board. System.out.println( turn + "'s turn; enter a slot number to place " + turn + " in:"); return null; } // To print out the board. /* |---|---|---| | 1 | 2 | 3 | |-----------| | 4 | 5 | 6 | |-----------| | 7 | 8 | 9 | |---|---|---|*/ static void printBoard() { System.out.println("|----|----|----|"); System.out.println("| " + board[0] + " | " + board[1] + " | " + board[2] + " |"); System.out.println("|--------------|"); System.out.println("| " + board[3] + " | " + board[4] + " | " + board[5] + " |"); System.out.println("|--------------|"); System.out.println("| " + board[6] + " | " + board[7] + " | " + board[8] + " |"); System.out.println("|----|----|----|"); } public static void main(String[] args) { Scanner in = new Scanner(System.in); board = new String[9]; turn = "X"; String winner = null; for (int a = 0; a < 9; a++) { board[a] = String.valueOf(a + 1); } System.out.println("Welcome to 3x3 Tic Tac Toe."); printBoard(); System.out.println( "X will play first. Enter a slot number to place X in:"); while (winner == null) { int numInput; // Exception handling. // numInput will take input from user like from 1 to 9. // If it is not in range from 1 to 9. // then it will show you an error "Invalid input." try { numInput = in.nextInt(); if (!(numInput > 0 && numInput
IX
XØ
ØXX
XOXO
Transcribed Image Text:IX XØ ØXX XOXO
X
ULTIMATE
TICTACTOE
PLAY
Transcribed Image Text:X ULTIMATE TICTACTOE PLAY
Expert Solution
steps

Step by step

Solved in 3 steps with 6 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY