-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHourGlass.java
More file actions
66 lines (55 loc) · 1.83 KB
/
HourGlass.java
File metadata and controls
66 lines (55 loc) · 1.83 KB
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
//This program uses for loops and static methods to output a scalable hour glass figure
public class HourGlass {
public static final int HEIGHT = 9; // scalable constant
public static void main(String[] args) {
Quotes();
TopTriangle();
DoubleLine();
BottomTriangle();
Quotes();
}
// This method outputs the quotation marks incased in the pipe symbol.
public static void Quotes() {
System.out.print("|");
for (int i = 1; i <= 2*HEIGHT+2; i++) {
System.out.print("\"");
}
System.out.print("|");
System.out.println();
}
// This method outputs the top of the triangular shape of the hour glass.
public static void TopTriangle() {
for (int i = 0; i < HEIGHT; i++) {
for (int j = 0; j <= i ; j++) {
System.out.print(" ");
}
System.out.print("\\");
for (int j = 1; j <= 2*HEIGHT- (2*i); j++) {
System.out.print(":");
}
System.out.print("/");
System.out.println();
}
}
// This method outputs the bottom of the triangular shape of the hour glass.
public static void BottomTriangle() {
for (int i = HEIGHT; i > 0; i--) {
for (int j = 0; j < i; j++) {
System.out.print(" ");
}
System.out.print("/");
for (int j = 0; j <= (2*HEIGHT - 2*i) + 1; j++) {
System.out.print(":");
}
System.out.print("\\");
System.out.println();
}
}
//This method outputs the double line that is in the center of the hour glass.
public static void DoubleLine() {
for(int i=0; i<=HEIGHT; i++){
System.out.print(" ");
}
System.out.println("||");
}
}