I have been asked to write a method that prints out the following pattern:
XXXXXXX
XXXXXX
XXXXX
XXXX
XXX
XX
X
instead of left-justified, i'm supposed to write a "right-justified" pattern.
I am not quite sure how i can write codes to insert the " " to get the above pattern.
So far, my codes are like these:
public void drawInvertedTriangle( int n )
{
for(int x=n; x>0; x--)
{
for(int y=1; y<=x;y++)
{
System.out.print("X");
}
System.out.println();
}
}
Any help would be appreciated, thank you!