The following code shows a simple roll of five dice.
If any two dice are matching, and the three other are also matching, I'd like to give the sum of the rolls. However, I'm not quite sure how to represent that while using an if statement.
Example: 4 4 3 4 3
Additionally, I'd like to figure out the same if the values of the dice can be arranged in a continuous wraparound sequence, (1 follows after 6).
Example: 6 1 2 3 4
Any help or advice would be appreciated, thank you!
int die1;
int die2;
int die3;
int die4;
int die5;
int roll;
die1 = (int)(Math.random()*6) + 1;
die2 = (int)(Math.random()*6) + 1;
die3 = (int)(Math.random()*6) + 1;
die4 = (int)(Math.random()*6) + 1;
die5 = (int)(Math.random()*6) + 1;
System.out.print("The roll was : " + die1 + " " + die2 + " " + die3 + " " + die4 + " " + die5 + " ");
Aucun commentaire:
Enregistrer un commentaire