public class FiveRow{ public static void main (String[] args) throws Exception {
ID: 3617149 • Letter: P
Question
public class FiveRow{
public static void main (String[] args) throws Exception
{
BufferedReader keyIn = new BufferedReader(newInputStreamReader(System.in));
char[][] B =new char[10][10]; // B is forBoard
booleanwin = false;
char[] c= {'X', '0'};
System.out.println(" ");
System.out.println(" ~~~~~~~~ 5 IN A ROW GAME~~~~~~~~");
System.out.println(" ");
//initializeour board
for(int i=0;i<10; i++)
for(int j=0; j<10; j++)
B[i][j] ='-';
//displayour board
for (inti=0; i<10; i++)
{
for(int j=0; j<10; j++)
System.out.print(" " +B[i][j]);
System.out.println();
}
for(intt=0; (t<9) || !win ; t++)
{
System.out.print("row =");
int row = Integer.parseInt(keyIn.readLine());
System.out.print("column = ");
int col = Integer.parseInt(keyIn.readLine());
B[row][col] = c[t%2]; //alternates between x's and0's
//display board
for(int i=0; i<10; i++)
{
for (int j=0;j<10;j++)
System.out.print(" " + B[i][j]);
System.out.println();
}
}
}
}
Explanation / Answer
please rate - thanks multiple players added import java.io.*; public class untitled { public static void main (String[] args)throws Exception { BufferedReader keyIn = new BufferedReader(newInputStreamReader(System.in)); char[][] B =new char[10][10]; // B is forBoard boolean win= false; intplayers; System.out.print("How many players are there? "); players =Integer.parseInt(keyIn.readLine()); char[] c =new char[players]; for(inti=0;iRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.