-
Notifications
You must be signed in to change notification settings - Fork 98
Expand file tree
/
Copy pathLetter_R.java
More file actions
55 lines (44 loc) · 1.19 KB
/
Copy pathLetter_R.java
File metadata and controls
55 lines (44 loc) · 1.19 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
package Pattern_Printing;
/*
Expected output =
##@@@
## @@@
## @@@
## @@@
##@@@
## @@
## @@
## @@
## @@
*/
public class Letter_R {
public static void main(String[] args) {
//prints at the start of each line
final String HASH = "##";
//for upper half of the R
final String THREE_ATS = "@@@";
//for the lower half of the r
final String TWO_ATS = "@@";
var tabs = " ";
var spaces = new StringBuilder(" ");
//Loop through upper half of the R
for (int i = 1; i < 6; i++) {
System.out.print(HASH);
//determines if any indentation is necessary
if (i % 2 == 0) {
System.out.print(tabs);
} else if (i == 3) {
System.out.print(tabs+tabs);
}
//prints the ascii for the R
System.out.print(THREE_ATS + "\n");
}
//loop through lower half of the R
for (int i = 0; i < 4; i++) {
System.out.print(HASH);
System.out.print(spaces + TWO_ATS + "\n");
//increases the space with each iteration of loop
spaces.append(" ");
}
}
}