Situation:
I am trying to convert the following for loop into a while loop:
final int MIN = 1;
final int MAX = 7;
int i=MIN,j=MIN;
for(i=MIN; i<=MAX;i++)
{
for(j=MIN;j<=MAX;j++)
{
if(i==j)
if(i==(MIN+MAX)/2)
System.out.print("o");
else
System.out.print("*");
else if (i+j == MIN+MAX)
System.out.print("*");
else
System.out.print(" ");
}
System.out.println();
}
I thought it was pretty simple:
while(i<=MAX)
{
while(j<= MAX)
{
if(i==j)
if(i==(MIN+MAX)/2)
System.out.print("o");
else
System.out.print("*");
else if (i+j == MIN+MAX)
System.out.print("*");
else
System.out.print(" ");
j++;
}
System.out.println();
i++;
}
however, for some unknown reason, when i>1, it never goes into the inner while loop. i'm not sure what i'm doing wrong...