Using Java program this: /* This program is preparing to play a Tic-tac-toe game. For now, it should only place X-s on the board in the place specified by the user on each turn.   Here, you should implement the method printBoard() that  should print a "board" passed to it. Notice that the board is SHIFTED to the right a bit. You should do it too!   Don't change your main.    Eventually your output should look something like this:        1 2 3     1 . . .     2 . . .     3 . . .  Where do you want to place X? Enter row and column (separated by blank space): 2 2      1 2 3     1 . . .     2 . X .     3 . . .  Where do you want to place X? Enter row and column (separated by blank space): 3 3      1 2 3     1 . . .     2 . X .     3 . . X  Where do you want to place X? Enter row and column (separated by blank space): ... ... and so on.   */   You can use this and complete the program:   import java.util.Scanner; public class PrepTicTacToe1{          public static void printBoard(String[][] board){     //  Print each element of the board as shown above     }       public static void main(String[] args){             Scanner scan = new Scanner(System.in);                String board [][]={                     {" ","1","2","3"},                     {"1",".",".","."},                     {"2",".",".","."},                     {"3",".",".","."}                    };        int row= 0;        int col= 0;                             do{                         printBoard(board);            System.out.println("Where do you want to place X?");            System.out.print("Enter row and column (separated by blank space): ");            row = scan.nextInt();            col = scan.nextInt();            if (row>3 || row<1 || col>3 || col<1){                System.out.println("...........................................Wrong input");                continue;            }            board[row][col]="X";        }while(true);                 } }

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
Using Java program this:
/*
This program is preparing to play a Tic-tac-toe game.
For now, it should only place X-s on the board in the
place specified by the user on each turn.
 
Here, you should implement the method printBoard() that 
should print a "board" passed to it. Notice that the board
is SHIFTED to the right a bit. You should do it too!
 
Don't change your main. 
 
Eventually your output should look something like this:
 
     1 2 3 
   1 . . . 
   2 . . . 
   3 . . . 
Where do you want to place X?
Enter row and column (separated by blank space): 2 2
     1 2 3 
   1 . . . 
   2 . X . 
   3 . . . 
Where do you want to place X?
Enter row and column (separated by blank space): 3 3
     1 2 3 
   1 . . . 
   2 . X . 
   3 . . X 
Where do you want to place X?
Enter row and column (separated by blank space): ...
...
and so on.
 
*/
 
You can use this and complete the program:
 
import java.util.Scanner;
public class PrepTicTacToe1{
    
    public static void printBoard(String[][] board){
    //  Print each element of the board as shown above
    }
 
    public static void main(String[] args){
    
       Scanner scan = new Scanner(System.in);
       
       String board [][]={
                    {" ","1","2","3"},
                    {"1",".",".","."},
                    {"2",".",".","."},
                    {"3",".",".","."}
                   };
       int row= 0;
       int col= 0;
                    
       do{             
           printBoard(board);
           System.out.println("Where do you want to place X?");
           System.out.print("Enter row and column (separated by blank space): ");
           row = scan.nextInt();
           col = scan.nextInt();
           if (row>3 || row<1 || col>3 || col<1){
               System.out.println("...........................................Wrong input");
               continue;
           }
           board[row][col]="X";
       }while(true);
           
    }
}
Expert Solution
Step 1

Answer:

Java Source Code:

import java.util.Scanner;
class Main {
    public static void printBoard(String [][] board)
    {
        System.out.print("\n");
        for(int x = 0;x < 4; x++)
        { 
            for(int y = 0; y < 4; y++)
            {
                System.out.print(board[x][y]+" ");
            }
            System.out.print("\n");
        }
    }

public static void main(String args[] ) {
    Scanner scan= new Scanner(System.in);
    String board [][]={{" ","1","2","3"},
                       {"1",".",".","."},
                       {"2",".",".","."},
                       {"3",".",".","."}};
    int row=0;
    int col=0;
    do{
        printBoard(board);
        System.out.println("Where do you want to place X?");
        System.out.print("Enter row and column (separated by blank space): ");
        row=scan.nextInt();
        col=scan.nextInt();
        if(row>3||row<1||col>3||col<1)
        {
            System.out.println("...............................Wrong Input");
            continue;
        }
        board[row][col]="X";
    }while(true);
}
}

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
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