I started school for CS last semester and it is awesome. I have been able to get through most of the work with little help. I have a question (which I hope is simple) about printing out five random dice in a HORIZONTAL row, rather than vertical:
snippet:
for (int i = 0; i < 5; i++){ randomValue = randomNumberGenerator.nextInt( 6) + 1; // get random number 0..5 and add 1 to it if (randomValue == 1){ // If statement for random # being 1 System.out.println("------- \n" + "| | \n" + "| * | \n" // Print out a 1 die + "| | \n" + "------- \n"); } else if (randomValue == 2){ // If statement for random # being 2 System.out.println("------- \n" + "|* | \n" + "| | \n" // Print out a 2 die + "| *| \n" + "------- \n"); } else if (randomValue == 3){ System.out.println("------- \n" + "|* | \n" // And so on... + "| * | \n" + "| *| \n" + "------- \n"); } else if (randomValue == 4){ System.out.println("------- \n" + "|* *| \n" + "| | \n" + "|* *| \n" + "------- \n"); } else if (randomValue == 5){ System.out.println("------- \n" + "|* *| \n" + "| * | \n" + "|* *| \n" + "------- \n"); } else if (randomValue == 6){ System.out.println("------- \n" + "|* *| \n" + "|* *| \n" + "|* *| \n" + "------- \n"); } }
This code currently prints out a graphical representation of 5 different dice vertically, I am wondering if somebody can tell me which steps to take to be able to print these out so they are horizontal and all in one row. I have tried reading about the printf() function but am unsure if that is the answer. Any help is appreciated thanks!