Hi,
I am facing problem with my coding but can't seems to find the problem with it. Can someone guide me?
//for loop
for (line=1; line <=height; line++)
{ for(col=1; col <=line; col++)
{
if (line%2 !=0)// odd line
{
if (col%2 != 0)//odd line,odd col
System.out.print(A);
else //(col%2 == 0) //odd line, even col
System.out.print(B);
}
if (line%2 == 0)//even line
{
if(col%2 !=0)//even line, odd col
System.out.print(A);
else //(col%2 == 0)//even line, even col
System.out.print(B);
}
}
}
}
else
System.out.println (height + "- Error input!!");
}
the output should be
AA
BBAA
AABBAA
when height = 3
but instead, my output is AAAABBAABBAA.
Thanks.
Regards,
Heels