Printing a grid. Write a program that prints the following grid to play tic-tac-
ID: 3544290 • Letter: P
Question
Printing a grid. Write a program that prints the following grid to play tic-tac-toe.
+--+--+--+
| | | |
+--+--+--+
| | | |
+--+--+--+
| | | |
+--+--+--+
(sorry for weird formatting, but the veritcal lines are supposed match up with the plus signs so it forms a sort of rectangular 'grid')
Of course, you could simply write seven statements of the form
System.out.println("+--+--+--+");
You should do it the smart way, though. Declare string variables to hold two kinds of patterns: a comb-shaped pattern and the bottom line. Print the comb three times and the bottom line once
Any help would be greatly appreciated. Again, this is the java programming language :)
Explanation / Answer
please rate - thanks
not sure this is what you want
import java.util.*;
public class main
{public static void main(String args[])
{String line="+--+--+--+ ";
String comb="| | | | ";
String TTT=line+comb+line+comb+line+comb+line;
System.out.print(TTT);
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.