Advertisement
Guest User

pattern

a guest
Feb 17th, 2020
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.68 KB | None | 0 0
  1. package com.stevehecker.starpattern;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Main {
  6.  
  7.     public static void main(String[] args) {
  8.  
  9.  
  10.         System.out.println("Enter number of digits for star pattern: ");
  11.         Scanner scan = new Scanner(System.in);
  12.        int amount =  scan.nextInt();
  13.  
  14.         for(int i = 1; i <= amount; i++) {
  15.             for(int j=0; j < i; j++) {
  16.                 System.out.println("*");
  17.             }
  18.             System.out.println();
  19.         }
  20.  
  21.  
  22.         for (int i=amount -1; i > 0; i--) {
  23.             for(int j=0; j < i; j++) {
  24.                 System.out.println("*");
  25.             }
  26.             System.out.println();
  27.         }
  28.  
  29.  
  30.  
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement