Skip to content

Commit d36ed92

Browse files
authored
Merge pull request #11 from code-for-tomorrow/JoshJ-JingleBellRelay
Jingle Bell Relay Problems
2 parents d061ae5 + 439e7fe commit d36ed92

File tree

11 files changed

+917
-2
lines changed

11 files changed

+917
-2
lines changed

.github/workflows/java-checkstyle.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ jobs:
2121
- name: Run checkstyle with reviewdog
2222
uses: nikitasavinov/[email protected]
2323
with:
24-
github_token: ${{ secrets.GITHUB_TOKEN }
24+
github_token: ${{ secrets.GITHUB_TOKEN }}
2525
# submit review comments based on reviewdog findings
2626
reporter: github-pr-review
2727
# report on anything that is in an added/modified file
28-
filter: file
28+
filter: file
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
package com.codefortomorrow.intermediate.chapter11.practice.JingleRelays;
2+
3+
/*
4+
This is the first of a series of problems.
5+
Credit: Christopher Haver, Computer Science, South Brunswick High School, New Jersey
6+
7+
Jingle Bell Challenge! Problem 1
8+
9+
Using ony method calls and the String song. Print
10+
"Jingle Bells Jingle Bells Jingle All The Way" vertically
11+
with one letter on each line. If you do so correctly
12+
the "You Win!" graphic will print at the bottom.
13+
14+
Only write code where the comments direct you to.
15+
*/
16+
17+
public class Jingle1 {
18+
19+
public static void main(String[] args) {
20+
String song = ""; //DO NOT CHANGE THESE
21+
String winningString =
22+
"J\ni\nn\ng\nl\ne\n\nB\ne\nl\nl\ns\n\nJ\ni\nn\ng\nl\ne\n\nB\ne\nl\nl\ns\n\nJ\ni\nn\ng\nl\ne\n\nA\nl\nl\n\nT\nh\ne\n\nW\na\ny\n\n";
23+
24+
/***** ONLY WRITE THE CODE BETWEEN THESE COMMENTS TO CALL METHODS FOR A SOLUTION ******/
25+
song += ""; //Build your string here using the methods below to match the winning string
26+
27+
/****** WRITE CODE ABOVE, NO CHANGES BELOW *******/
28+
29+
System.out.println(song);
30+
if (song.equals(winningString)) win(); else System.out.println(
31+
"Sorry, not quite right"
32+
);
33+
}
34+
35+
// YOU MAY NOT CHANGE ANY OF THE METHODS BELOW
36+
37+
public static String jingle() {
38+
return "J\ni\nn\ng\nl\ne\n\n";
39+
}
40+
41+
public static String end(double x) {
42+
String outString = "A\nl\nl\n\n";
43+
x *= -3.3;
44+
if (x < 0) outString += "N\ni\ng\nh\nt\n\n";
45+
if (x != 0) outString += "T\nh\ne\n\nW\na\ny\n\n"; else outString +=
46+
"Y\no\nu\n\nW\na\nn\nt\n\n";
47+
return outString;
48+
}
49+
50+
public static String jingleBells(int x) {
51+
String outString = "";
52+
if (x == 2) {
53+
outString += jingle() + "B\ne\nl\nl\ns\n\n";
54+
}
55+
outString += jingle() + "B\ne\nl\nl\ns\n\n";
56+
return outString;
57+
}
58+
59+
public static void win() {
60+
System.out.println("\n YOU WIN! \n");
61+
System.out.println(" ((\\o/)) ");
62+
System.out.println(" .-----//^\\\\-----. ");
63+
System.out.println(" | /`| |`\\ | ");
64+
System.out.println(" | | | | ");
65+
System.out.println(" | | | | ");
66+
System.out.println(" | | | | ");
67+
System.out.println(" '------===------' \n\n");
68+
}
69+
}
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
package com.codefortomorrow.intermediate.chapter11.practice.JingleRelays;
2+
3+
/*
4+
This is the second of a series of problems.
5+
Credit: Christopher Haver, Computer Science, South Brunswick High School, New Jersey
6+
7+
Using ony method calls and the String song. Print
8+
"Jingle Bells Jingle Bells Jingle All The Way" vertically
9+
with one letter on each line. If you do so correctly
10+
the "You Win!" graphic will print at the bottom.
11+
*/
12+
13+
public class Jingle2 {
14+
15+
public static void main(String[] args) {
16+
String song = ""; //DO NOT CHANGE THESE
17+
String winningString =
18+
"J\ni\nn\ng\nl\ne\n\nB\ne\nl\nl\ns\n\nJ\ni\nn\ng\nl\ne\n\nB\ne\nl\nl\ns\n\nJ\ni\nn\ng\nl\ne\n\nA\nl\nl\n\nT\nh\ne\n\nW\na\ny\n\n";
19+
20+
/***** ONLY WRITE THE CODE BETWEEN THESE COMMENTS TO CALL METHODS FOR A SOLUTION ******/
21+
song += ""; //Build your string here using the methods below to match the winning string
22+
23+
/****** WRITE CODE ABOVE, NO CHANGES BELOW *******/
24+
25+
System.out.println(song);
26+
if (song.equals(winningString)) win(); else System.out.println(
27+
"Sorry, not quite right"
28+
);
29+
}
30+
31+
// YOU MAY NOT CHANGE ANY OF THE METHODS BELOW
32+
33+
public static String ingle() {
34+
return "i\nn\ng\nl\ne\n\n";
35+
}
36+
37+
public static String J() {
38+
return "J\n";
39+
}
40+
41+
public static String B() {
42+
return "B\n";
43+
}
44+
45+
public static String end(boolean x, boolean y) {
46+
String outString = "A\nl\nl\n\n";
47+
if (!(x || !y)) outString += "N\ni\ng\nh\nt\n\n";
48+
if (x != y && !y) outString += "T\nh\ne\n\nW\na\ny\n\n";
49+
if (x == y && x) outString += "Y\no\nu\n\nW\na\nn\nt\n\n";
50+
return outString;
51+
}
52+
53+
public static String ingleElls(String a, String b) {
54+
switch (a) {
55+
case "j":
56+
a = J();
57+
break;
58+
case "J":
59+
a = "j\n\n";
60+
break;
61+
default:
62+
a = "B\n\n";
63+
}
64+
switch (b) {
65+
case "b":
66+
b = B();
67+
break;
68+
case "B":
69+
b = "b\n\n";
70+
break;
71+
default:
72+
a = "J\n\n";
73+
}
74+
75+
return a + ingle() + b + "e\nl\nl\ns\n\n";
76+
}
77+
78+
public static void win() {
79+
System.out.println("\n YOU WIN! \n");
80+
System.out.println(" ((\\o/)) ");
81+
System.out.println(" .-----//^\\\\-----. ");
82+
System.out.println(" | /`| |`\\ | ");
83+
System.out.println(" | | | | ");
84+
System.out.println(" | | | | ");
85+
System.out.println(" | | | | ");
86+
System.out.println(" '------===------' \n\n");
87+
}
88+
}
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
package com.codefortomorrow.intermediate.chapter11.practice.JingleRelays;
2+
3+
/*
4+
This is the third of a series of problems.
5+
Credit: Christopher Haver, Computer Science, South Brunswick High School, New Jersey
6+
7+
Using ony method calls and the String song. Print
8+
"Jingle Bells Jingle Bells Jingle All The Way" vertically
9+
with one letter on each line. If you do so correctly
10+
the "You Win!" graphic will print at the bottom.
11+
*/
12+
13+
public class Jingle3 {
14+
15+
public static void main(String[] args) {
16+
String song = ""; //DO NOT CHANGE THESE
17+
String winningString =
18+
"J\ni\nn\ng\nl\ne\n\nB\ne\nl\nl\ns\n\nJ\ni\nn\ng\nl\ne\n\nB\ne\nl\nl\ns\n\nJ\ni\nn\ng\nl\ne\n\nA\nl\nl\n\nT\nh\ne\n\nW\na\ny\n\n";
19+
20+
/***** ONLY WRITE THE CODE BETWEEN THESE COMMENTS TO CALL METHODS FOR A SOLUTION ******/
21+
22+
song += ""; //Build your string here using the methods below to match the winning string
23+
24+
/****** WRITE CODE ABOVE, NO CHANGES BELOW *******/
25+
26+
System.out.println(song);
27+
if (song.equals(winningString)) win(); else System.out.println(
28+
"Sorry, not quite right"
29+
);
30+
}
31+
32+
// YOU MAY NOT CHANGE ANY OF THE METHODS BELOW
33+
34+
public static String jingle() {
35+
return "J\ni\nn\ng\nl\ne\n\n";
36+
}
37+
38+
public static String end(int a, int b, int c, int d, int e) {
39+
String outString = "A\nl\nl\n\n";
40+
int sum = a + b + c + d + e;
41+
double mean = (a + b + c + d + e) / 5.0;
42+
if (sum >= 473) if (a != b && b != c && c != d && d != e) if (
43+
mean == 100.0
44+
) outString += "T\nh\ne\n\nW\na\ny\n\n"; else outString +=
45+
"N\ni\ng\nh\nt\n\n"; else outString +=
46+
"Y\no\nu\n\nW\na\nn\nt\n\n"; else outString +=
47+
"A\nr\no\nu\nn\nd\n\n";
48+
return outString;
49+
}
50+
51+
public static String jingleBells(int a, int b) {
52+
String outputString = "";
53+
switch (a % 7) {
54+
case 6:
55+
outputString += "J\n";
56+
case 5:
57+
outputString += "i\n";
58+
case 4:
59+
outputString += "n\n";
60+
case 3:
61+
outputString += "g\n";
62+
case 2:
63+
outputString += "l\n";
64+
case 1:
65+
outputString += "e\n";
66+
default:
67+
outputString += "\n";
68+
}
69+
70+
switch (a / b) {
71+
case 6:
72+
outputString += "B\ne\nl\nl\ns\n\n";
73+
break;
74+
default:
75+
outputString += "B\nl\no\nr\np\n\n";
76+
}
77+
return outputString;
78+
}
79+
80+
public static void win() {
81+
System.out.println("\n YOU WIN! \n");
82+
System.out.println(" ((\\o/)) ");
83+
System.out.println(" .-----//^\\\\-----. ");
84+
System.out.println(" | /`| |`\\ | ");
85+
System.out.println(" | | | | ");
86+
System.out.println(" | | | | ");
87+
System.out.println(" | | | | ");
88+
System.out.println(" '------===------' \n\n");
89+
}
90+
}
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
package com.codefortomorrow.intermediate.chapter11.practice.JingleRelays;
2+
3+
/*
4+
This is the fourth of a series of problems.
5+
Credit: Christopher Haver, Computer Science, South Brunswick High School, New Jersey
6+
7+
Using ony method calls and the String song. Print
8+
"Jingle Bells Jingle Bells Jingle All The Way" vertically
9+
with one letter on each line. If you do so correctly
10+
the "You Win!" graphic will print at the bottom.
11+
*/
12+
13+
public class Jingle4 {
14+
15+
public static void main(String[] args) {
16+
String song = ""; //DO NOT CHANGE THESE
17+
String winningString =
18+
"J\ni\nn\ng\nl\ne\n\nB\ne\nl\nl\ns\n\nJ\ni\nn\ng\nl\ne\n\nB\ne\nl\nl\ns\n\nJ\ni\nn\ng\nl\ne\n\nA\nl\nl\n\nT\nh\ne\n\nW\na\ny\n\n";
19+
20+
/***** ONLY WRITE THE CODE BETWEEN THESE COMMENTS TO CALL METHODS FOR A SOLUTION ******/
21+
22+
song += ""; //Build your string here using the methods below to match the winning string
23+
/****** WRITE CODE ABOVE, NO CHANGES BELOW *******/
24+
25+
System.out.println(song);
26+
if (song.equals(winningString)) win(); else System.out.println(
27+
"Sorry, not quite right"
28+
);
29+
}
30+
31+
// YOU MAY NOT CHANGE ANY OF THE METHODS BELOW
32+
33+
public static String end(boolean a, boolean b, boolean c, boolean d) {
34+
boolean flag = (!(a && !b) || c && !d);
35+
String outString = "";
36+
if (flag) outString =
37+
"A\nl\nl\n\nT\nh\ne\n\nW\na\ny\n\n"; else outString =
38+
"A\nl\nl\n\nD\na\ny\n\nL\no\nn\ng\n\n";
39+
40+
return outString;
41+
}
42+
43+
public static String jingleBells(int a) {
44+
String outputString = "";
45+
switch ((a / 2) % 17) {
46+
case 12:
47+
outputString += "\n";
48+
break;
49+
case 11:
50+
outputString += "B\n";
51+
case 10:
52+
outputString += "e\n";
53+
case 9:
54+
outputString += "l\n";
55+
case 8:
56+
outputString += "l\n";
57+
case 7:
58+
outputString += "s\n";
59+
break;
60+
case 6:
61+
outputString += "J\n";
62+
case 5:
63+
outputString += "i\n";
64+
case 4:
65+
outputString += "n\n";
66+
case 3:
67+
outputString += "g\n";
68+
case 2:
69+
outputString += "l\n";
70+
case 1:
71+
outputString += "e\n\n";
72+
break;
73+
}
74+
75+
return outputString;
76+
}
77+
78+
public static void win() {
79+
System.out.println("\n YOU WIN! \n");
80+
System.out.println(" ((\\o/)) ");
81+
System.out.println(" .-----//^\\\\-----. ");
82+
System.out.println(" | /`| |`\\ | ");
83+
System.out.println(" | | | | ");
84+
System.out.println(" | | | | ");
85+
System.out.println(" | | | | ");
86+
System.out.println(" '------===------' \n\n");
87+
}
88+
}

0 commit comments

Comments
 (0)