-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAdvancedAstrology.java
69 lines (53 loc) · 1.52 KB
/
AdvancedAstrology.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
59
60
61
62
63
64
65
66
67
68
69
public class AdvancedAstrology {
public static void printStars(int number) {
// part 1 of the exercise
for (int i = 0; i < number; i++){
System.out.print("*");
}
System.out.println("");
}
public static void printSpaces(int number) {
// part 1 of the exercise
for (int i= 0; i < number; i++){
System.out.print(" ");
}
}
public static void printTriangle(int size) {
// part 2 of the exercise
int j = size - 1;
for(int i= 1; i <= size; i++){
printSpaces(j);
printStars(i);
j--;
}
}
public static void christmasTree(int height) {
// part 3 of the exercise
int j = height - 1;
int k = 0;
int n = 1;
for (int i = 1; i <= height; i++){
printSpaces(j);
printStars(i+k);
k++;
j--;
}
while(n<=2){
printSpaces(height-2);
printStars(3);
n++;
}
}
public static void main(String[] args) {
// The tests are not checking the main, so you can modify it freely.
printStars(1);
System.out.println("---");
printSpaces(1);
System.out.println("---");
printTriangle(5);
System.out.println("---");
christmasTree(4);
System.out.println("---");
christmasTree(10);
}
}