samedi 30 octobre 2021

Java program to ask user for a 6 digit sequence of face of a die(1-6), randomly roll the dice until we get the user input sequence. Print the attempt

Ask user for a 6 digit sequence of face of a die(1-6), randomly roll the dice until we get the user input sequence in order as the user put it in. Print the number of dice roll it took to print that sequence.

Example: Enter your sequence: 436232 The sequence '436232' took 872123 dice rolls


I think we can make a testSequence 000000 and concat every random dice face with the sample string and quit the loop once the concatonated string matches the user input sequence. But i dont know how to execute this.




Aucun commentaire:

Enregistrer un commentaire