Sunday, 19 August 2018

how print two parallel triangle pattern in java


if you solve pattern problem then you grow your program solving ability  in java programming.
 hello dear student I am providing pattern solution of Java programming you can use this solution in your ICSE  board

exam and  find your goal  in this post we are providing two parallel triangle  pattern solution and  print it with stick.
how print two parallel triangle  pattern in java 
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package patterns;

/**
 *
 * @author rajesh kumar shukla
 */
public class pattern4 {
   


    public static void main(String[] args) {
        int number = 8;

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

            if (i != number - 1) {
                System.out.print(" ");
            } else {
                System.out.print(" *");
            }
            for (int j = 0; j <= i; ++j) {
                System.out.print("*");
            }

            System.out.println();
        }
    }
}

output
run:
* *
** **
*** ***
**** ****
***** *****
****** ******
******* *******
******** *********

0 comments:

Post a Comment