Complete the printTicTacToe method with char parameters horizChar and vertChar t
ID: 3757906 • Letter: C
Question
Complete the printTicTacToe method with char parameters horizChar and vertChar that prints a tic-tac-toe board with the characters as follows. End with newline. Ex: printTicTacToe('~', '!') prints:
Hint: To ensure printing of characters, start your print statement as: System.out.println("" + horizChar ...).
import java.util.Scanner;
public class GameBoardPrinter {
public static void printTicTacToe(char horizChar, char vertChar) {
/* Your solution goes here */
return;
}
public static void main (String [] args) {
printTicTacToe('~', '!');
return;
}
}
Explanation / Answer
package mani;
import java.util.Scanner;
public class GameBoardPrinter {
public static void printTicTacToe(char horizChar, char vertChar) {
System.out.println("x"+vertChar+"x"+vertChar+"x"+vertChar);
System.out.println(horizChar+""+horizChar+""+horizChar+""+horizChar+""+horizChar);
System.out.println("x"+vertChar+"x"+vertChar+"x"+vertChar);
System.out.println(horizChar+""+horizChar+""+horizChar+""+horizChar+""+horizChar);
System.out.println("x"+vertChar+"x"+vertChar+"x"+vertChar);
return;
}
public static void main (String [] args) {
printTicTacToe('~', '!');
return;
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.