Hi, I need help with this program here. I want to print an isosceles triangle. But, I keep ending up with this here where they are being spaced:
--------*
-------* *
------* * *
-----* * * *
----* * * * *
---* * * * * *
--* * * * * * *
-* * * * * * * *
* * * * * * * * *
* * * * * * * * * *
Here is my code for it:

int num = 10;
		int i;
		int k;
		int j;
		
		for(i = 1; i <= num; i++) 
		{
			for(k = num; k >= i; k--)
			{
				System.out.print(" ");
			}
	
			for(j = 1; j <= i; j++) 
			{
				System.out.print("*");
				System.out.print(" ");
			}

			System.out.println();
		}

Even when I remove the "System.out.print(" ");" in the third for loop,

for(j = 1; j <= i; j++) 
			{
				System.out.print("*");
				System.out.print(" ");
			}

it would end up like this:
--------------*
-------------**
-----------***
----------****
--------*****
------******
-----*******
---********
--*********
**********
So can anyone help me on this? Thanks.
(Note: Sorry if I didn't draw the triangles correctly. This is my first time doing this)

whats the problem? this code already prints an isosceles triangle?

whats the problem? this code already prints an isosceles triangle?

sorry... now I see that you are complaining about spaces...

your are incrementing the asteriks one by one in every line.. if you dont want spaces, then you should go with 1-3-5-7-9... asteriks on each line....

sorry... now I see that you are complaining about spaces...

your are incrementing the asteriks one by one in every line.. if you dont want spaces, then you should go with 1-3-5-7-9... asterisk on each line....

Nevermind, I sort of did read the directions of the homework my professor has given us incorrectly. It's suppose to have spaces separating them and I sort of miss reading that part lol. In my professor's website, he forgot to put spaces in that triangle he wanted us to do and I just assumed that he wanted to make it without any spaces :p. Anyways, thanks for your help though and I did what you said and that works too. I apologize for this and again thanks. :)

Nevermind, I sort of did read the directions of the homework my professor has given us incorrectly. It's suppose to have spaces separating them and I sort of miss reading that part lol. In my professor's website, he forgot to put spaces in that triangle he wanted us to do and I just assumed that he wanted to make it without any spaces :p. Anyways, thanks for your help though and I did what you said and that works too. I apologize for this and again thanks. :)

oh teachers... :)

oh teachers... :)

lol. Yeah, I know. Drove me crazy over the weekend. XD