My program needs to throw 2 dices and when both are 6 it gets out of the loop and show me how many times it tries, but for some reason I get very wierd try numbers like, most of them are "it took 1-3 tries".. Help plz.
public class SheshBesh {
public static void main(String[] args){
int r1 = 0;
int r2 = 0;
int tries = 0;
while (r1 != 6 && r2 != 6) {
r1 = (int)(Math.random() * 6) + 1;
r2 = (int)(Math.random() * 6) + 1;
tries = tries + 1;
}
System.out.println("Shesh-Besh apears... it took " + tries + " tries.");
}
}
Aucun commentaire:
Enregistrer un commentaire