Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding the Letter R class to the Pattern_Printing class #347

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions Pattern_Printing/Letter_R.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,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(" ");
}
}
}