Java program for Triangle Part – 3

By |2018-12-05T08:04:05+05:30June 18th, 2016|java programs|

In this tutorials, we are going write a Java Program For Triangle Part 3 to create a below. This is a Part 3  of the complete example. You can follow the complete 4 parts to complete the entire example.

Java program for Triangle Part – 3 :

Triangle_Top_LeftToRight.java
package com.onlinetutorialspoint.patterns;
import java.util.Scanner;

/*
 * *
 * **
 * ***
 * ****
 * *****
 */
public class Triangle_Top_LeftToRight {
    public static void main(String args[]) {
        /* Getting the input from keyboard */
        Scanner scanner = new Scanner(System.in);
        System.out.println("Enter the size of Triangle");
        int size = scanner.nextInt();
        for (int i = 1; i <= size; i++) {
            for (int j = 1; j <= i; j++) {
                System.out.print("*");
            }
            System.out.println();
        }
    }
}

By running the above Java program, you can get the below shape.

Output :

Terminal

javac  Triangle_Down_RightToLeft.java
java  Triangle_Down_RightToLeft

Java Program for Triangle Part - 3Happy Learning 🙂

About the Author:

Hi Folks, you have reach this so far, that shows you like what you are learning. Then why don't you support us to improve for bettor tutorials by leaving your valuable comments and why not you keep in touch with us for latest updates on your favorite blog @ facebook , twitter , Or Google+ ,

Leave A Comment