0

So I did the first part of my assisgnment like this
*
**
***
****
*****
******
*******
********
*********
using this code

public class starForTest
{
	public static void main(String [] args)
	{
		for (int i=1; i<=9; i++)
		{
			System.out.println();
			for (int j=9; j>=i; j--)
			{
				System.out.print(" ");
			}
		 for (int k=1; k<=i; k++)
		 {
		 	System.out.print("*");
		 }	
	            }
	System.out.println();	
	}
}

but now i need to flip it to make it look like this
*****
****
***
**
*
but i dont't know how.

3
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by NormR1
0

Do you just want 123456789987654321?

for (int i=1; i<=9; i++){	
   System.out.println("i"+i);
}		

for (int j=9; j>=i; j--){						
   System.out.println(j"+j);
}

But there's probably a more expert way of doing this...

Edited by StephNicolaou: n/a

0

Think about how the first program controls how many * it prints on a line. It starts at one and moves on to a max number.
Now rework the logic so it starts at the max number and works done to one.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.