mardi 13 janvier 2015

How do i make an if statement if one is a pair and other is not it is not lucky but if both is a pair it is lucky?

I have my if-else if-else statement to be



for (int counter = 1; counter<3; counter++) {
A = rand.nextInt(MAX_DICE + 1);
B = rand.nextInt(MAX_DICE + 1);
C = rand.nextInt(MAX_DICE + 1);
System.out.println(A + " " + B + " " + C);

if (A == B & A == C) {
System.out.println("You rolled 3 of a kind.");
}
else if (A == B) {
System.out.println("You rolled a pair.");
}
else if (B == C) {
System.out.println("You rolled a pair.");
}
else if (A == C) {
System.out.println("You rolled a pair.");
}
else {


How do I make it so after the coding statements it would say if it had 2 pairs or pair and triple the result would end up as You are lucky, but if it had only 1 pair or no pairs it would say you are not lucky?


For example:



4 5 3

You rolled nothing.

2 2 2

You rolled 3 of a kind.

You are NOT lucky.



Aucun commentaire:

Enregistrer un commentaire