-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPattern6.java
36 lines (30 loc) · 842 Bytes
/
Pattern6.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
import java.util.Scanner;
public class Pattern6 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("enter a number: ");
int n = sc.nextInt();
int star = n/2+1;
int space = 1;
for(int i=1; i<=n; i++){
for(int j=1; j<=star; j++){
System.out.print("*\t");
}
for(int j=1; j<=space; j++){
System.out.print("\t");
}
for(int j=1; j<=star; j++){
System.out.print("*\t");
}
if(i<=n/2){
star--;
space += 2;
}
else{
star++;
space -= 2;
}
System.out.println();
}
}
}