I was writing this simple loop and it's giving me trouble. It's supposed to count through the permutations in a deck, so Suit is supposed to go as high as Suit: 3 and Rank is supposed to go as high as Rank: 12, but it isn't doing that. My program output, followed by my code is below.
Welcome to DrJava. Working directory is /Volumes/LA-PUBLIC/TestProg2
> run loopNumbers
Rank: 0and Suit: 0
Rank: 0and Suit: 1
Rank: 0and Suit: 2
Rank: 1and Suit: 0
Rank: 1and Suit: 1
Rank: 1and Suit: 2
Rank: 2and Suit: 0
Rank: 2and Suit: 1
Rank: 2and Suit: 2
Rank: 3and Suit: 0
Rank: 3and Suit: 1
Rank: 3and Suit: 2
Rank: 4and Suit: 0
Rank: 4and Suit: 1
Rank: 4and Suit: 2
Rank: 5and Suit: 0
Rank: 5and Suit: 1
Rank: 5and Suit: 2
Rank: 6and Suit: 0
Rank: 6and Suit: 1
Rank: 6and Suit: 2
Rank: 7and Suit: 0
Rank: 7and Suit: 1
Rank: 7and Suit: 2
Rank: 8and Suit: 0
Rank: 8and Suit: 1
Rank: 8and Suit: 2
Rank: 9and Suit: 0
Rank: 9and Suit: 1
Rank: 9and Suit: 2
Rank: 10and Suit: 0
Rank: 10and Suit: 1
Rank: 10and Suit: 2
Rank: 11and Suit: 0
Rank: 11and Suit: 1
Rank: 11and Suit: 2
>
public class loopNumbers{
public static void main(String args[]){
int index=0;
for (int rank = 0; rank < 12; ++rank) {
for (int suit = 0; suit < 3; ++suit){
System.out.println("Rank: "+ rank +"and Suit: "+ suit);
index++;
}
}
}
}