I'm trying to create a program as described in the image linked below. I'm finding trouble with how to print the characters on the same line so that I can get 20 across and how to go to a new line after the first 20 characters have printed. Can you help me figure out a way to print the randomly selected characters into a 20 by 7 grid? Thank you for the help! Below is what I have so far but it's printing every new character on its own line and for gridArray[3] the forward-slash has to have two quotes otherwise it says that it's not a valid string. Does anyone know how I could solve these problems?
package edu.skidmore.cs106.lab09.problem14;
import java.util.Random;
public class GridGenorator {
public static void main(String[] args) {
// TODO Auto-generated method stub
String[] gridArray = new String[6];
gridArray[0] = "+";
gridArray[1] = "-";
gridArray[2] = "/";
gridArray[3] = "\"";
gridArray[4] = "|";
gridArray[5] = "_";
for (int elementx = 0; elementx < 7; elementx++) {
for(int elementy = 0; elementy<20; elementy++) {
Random rand = new Random();
int randomNum = rand.nextInt(6);
System.out.println(gridArray[randomNum]);
}
}
}
}