-
Notifications
You must be signed in to change notification settings - Fork 67
/
Copy pathPattern10.java
40 lines (38 loc) · 937 Bytes
/
Pattern10.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package com.java.patterns;
import java.util.Scanner;
/*
Write a Java Program to print the following Pattern
5 5 5 5 5 5 5 5 5
4 4 4 4 4 4 4
3 3 3 3 3
2 2 2
1
*/
public class Pattern10 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Enter the number of rows to print the pattern :: ");
int N = Integer.parseInt(scanner.nextLine().trim());
for(int i=N;i>=1;i--){
for(int j=0;j<2*(N-i);j++)
System.out.print(" ");
for(int j=0;j<(2*i)-1;j++)
if( j == 0)
System.out.print("*");
else
System.out.print(" *");
if(i > 1 )
System.out.println();
}
scanner.close();
}
}
/*
OUTPUT
Enter the number of rows to print the pattern :: 5
5 5 5 5 5 5 5 5 5
4 4 4 4 4 4 4
3 3 3 3 3
2 2 2
1
*/