For a school assignment I need to work with do/while/for loops(which suits the best) with randomized dice throws. The program stops once it throws a 6. But the output needs to look like the input char I give. I know that I need to use system.out.printf to format the output. It stops once the dice throws 6 characters. Would be great if someone could explain how and why too, so I can learn it for the next time.
Here's an example output:
# #
#
# #
# #
#
# #
#
#
#
# #
# #
# #
Code I have so far(also experimenting right now):
package com.company;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("What character do you want to use: ");
String character = input.nextLine();
char character2 = character.charAt(0);
do{
//math random probably needs to be put here?
System.out.printf("%1s %2s\n",character2, character2); //formatting of output, not yet finished
} while();
//not sure if do while is better in this situation. For loops possible too?
}
}