0

This is my program

import java.util.*;

class Triangle
{
public static void main(String Vinod[])
{
int i,j,n;
Scanner sc=new Scanner(System.in);
System.out.print("Enter a height of triangle : ");
n=sc.nextInt();
for(i=1;i<=n;i++)
{
    for(j=1;j<=i;j++)
    {
        System.out.print("*");
    }
    System.out.println();
}
for(j=n;j<=1;j--)
{
    for(i=j;i<=1;i--)
    {
        System.out.print("*");
    }
    System.out.println();
}
}
}

I dont know what to do now

My o/p is this:

*
**
***
****

but i want o/p like this:

*
**
***
****
***
**
*
2
Contributors
2
Replies
4
Views
4 Years
Discussion Span
Last Post by vinnitro
1

The code needs to continue after printing line 6 to print the rest of the lines.

What are the rules for formatting the rest of the lines after the full length line? It could be the reverse of the lines printed before the full length line.

Use a piece of paper and a pencil to draw the lines on and to an analyze what is printed on each line as the line numbers increase.

Edited by NormR1

This question has already been answered. 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.