Computer Science, asked by yashikkhurana680, 26 days ago

How to write a java program that prints a triangle based on the specified input which indicates the height of the triangle. For example, if the input is 5, then the output is as follows. 1 22 333 4444 55555

Answers

Answered by AriffZack
0

Answer:import java.util.Scanner;

public class TriangleInput {

public static void main(String[] args) {

 // TODO Auto-generated method stub

 Scanner sc = new Scanner(System.in);

 System.out.print("");

 

 int a = sc.nextInt();

 

 for(int i=1;i<=a;i++) {

 

 for(int j=1;j<=i;j++)

 

 System.out.print(i);

    System.out.println("");

       

    sc.close();

 }

}

}

Explanation:

Similar questions