We wrote this code in the lesson on nested loops.
public void printRectangle()
{
for ( int row = 0 ; row < height ; row++ )
{
// PRINT a row
for ( int col = 0 ; col < width ; col++ )
{
System.out.print( "*" ) ;
}
// PRINT newline
System.out.println( "" ) ;
}
}
Let's try a simple variation. We'll print it sideways.
Thus, we have width rows, and height columns.
All we have to do is to swap width and height,
and we're done!
public void printRectangle()
{
for ( int row = 0 ; row < width ; row++ )
{
// PRINT a row
for ( int col = 0 ; col < height ; col++ )
{
System.out.print( "*" ) ;
}
// PRINT newline
System.out.println( "" ) ;
}
}