-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchallenge01.java
56 lines (53 loc) · 1.79 KB
/
challenge01.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
// Print >>> Reverse Right Half Pyramid 🚀
// Print >>> Left Half Pyramid 🚀
// Print >>> Right Half Pyramid 🚀
// Print >>> Reverse Right Half Pyramid using while loop 🚀
public class challenge1 {
public static void main(String[] args) {
System.out.println("calling first pattern");
printfirstpattern();
System.out.println("calling second pattern");
printsecondpattern();
System.out.println("calling third pattern");
printthirdpattern();
System.out.println("print first pattern using while loop ");
printFirstPattern2Way();
}
public static void printsecondpattern() {
// Reverse Right Half Pyramid
System.out.println("* * * * *");
System.out.println("* * * *");
System.out.println("* * *");
System.out.println("* *");
System.out.println("*\n\n");
}
public static void printthirdpattern() {
// Left Half Pyramid
System.out.println(" *");
System.out.println(" * *");
System.out.println(" * * *");
System.out.println(" * * * *");
System.out.println("* * * * *\n\n");
}
public static void printfirstpattern() {
// Right Half Pyramid
System.out.println("*");
System.out.println("* *");
System.out.println("* * *");
System.out.println("* * * *");
System.out.println("* * * * *\n\n");
}
public static void printFirstPattern2Way() {
int rows = 0;
while(rows < 10){
System.out.print("*");
int i = 0;
while(i < rows){
System.out.print(" *");
i++;
}
System.out.println(" ");
rows++;
}
}
}