-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPattern59.java
58 lines (47 loc) · 1.22 KB
/
Pattern59.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
width = 3, height = 4
*
* *
* * *
* * *
* * * *
* * * * *
* * * * *
* * * * * *
* * * * * * *
* * * * * * *
* * * * * * * *
* * * * * * * * *
* * *
* * *
* * *
*/
import java.util.Scanner;
public class Pattern59 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter Christmas Tree Width & Height: ");
int width = sc.nextInt();
int height = sc.nextInt();
int n = 1;
int space = width * height;
for (int x=1; x<=height; x++) {
for (int i=n; i<=width; i++) {
for (int j=space; j>=i; j--)
System.out.print(" ");
for (int k=1; k<=i; k++)
System.out.print("* ");
System.out.println();
}
n = n + 2;
width = width + 2;
}
for (int i=1; i <=height-1; i++) {
for (int j=space-3; j>=0; j--)
System.out.print(" ");
for (int k=1; k<= height-1; k++)
System.out.print("* ");
System.out.println();
}
}
}