Chelsea S. asked

💻  Computer

Write a program called Problem3. This program reads in a sequence of X and O and stores them into a 2D array (3 X 3). It also reads an integer (N). The program will look at the 2D array row by row, column by column (and diagonally) to see if it contains three X’s or three O’s. For all rows, columns and the diagonals (top corners to bottom corners) that contain three X’s or three O’s, print the Row number (starts at row 0), Column number (starts at column 0), and the Diagonal (right or left). Read in a sequence of X’s and O’s that would fill a 2D grid (3 x 3) -> three rows and three columns. Print out all the rows, columns and diagonals of matching Os and Xs NOTE THE ORDER TO PRINT: matching rows, then matching columns, then left-hand diagonal and finally right-hand diagonals. There is no output if there are no matches. To make this problem more challenging – create 3 methods: one to find and print the rows, one to find and print the columns and one to find any diagonals. Call the methods from your main method and pass in the 2D array into each method.

August 1st, 2024

Carlos C. answered

Here's a Java solution for Problem3. In this program, we'll define three separate methods to check r...

August 1st, 2024

Sign Up to View Full Expert Answers

Create an account to view answers and interact with the community!

Sign Up with Email