Skip to content

Commit f770358

Browse files
wboccardAadit Kamat
and
Aadit Kamat
authored
Solution for Day 1 Problem using Java (#355)
* Add @wboccard as a contributor * solution for FizzBuzz in Java * Update package.json * Regenerate package-lock.json Co-authored-by: Aadit Kamat <[email protected]>
1 parent bac69d4 commit f770358

File tree

6 files changed

+310
-773
lines changed

6 files changed

+310
-773
lines changed

Diff for: .all-contributorsrc

+13-3
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@
298298
"contributions": [
299299
"code"
300300
]
301-
},
301+
},
302302
{
303303
"login": "gaurav01k3",
304304
"name": "GAURAV KUMAR",
@@ -307,7 +307,17 @@
307307
"contributions": [
308308
"doc",
309309
"code"
310-
]
311-
}
310+
]
311+
},
312+
{
313+
"login": "wboccard",
314+
"name": "wboccard",
315+
"avatar_url": "https://avatars3.githubusercontent.com/u/72316984?v=4",
316+
"profile": "https://github.com/wboccard",
317+
"contributions": [
318+
"doc",
319+
"code"
320+
]
321+
}
312322
]
313323
}

Diff for: CONTRIBUTORS.md

+6-5
Large diffs are not rendered by default.

Diff for: Day1/Java/FizzBuzz_wb.java

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* @author wboccard
3+
* @date October 7, 2020
4+
*/
5+
6+
public class FizzBuzz_wb {
7+
8+
public static void main(String[] args){
9+
int repetitions = 50;
10+
for (int index = 1; index <= repetitions; index++){
11+
if (index % 3 == 0 && index % 5 == 0){
12+
System.out.print("FizzBuzz");
13+
} else if (index % 3 == 0){
14+
System.out.print("Fizz");
15+
} else if (index % 5 == 0){
16+
System.out.print("Buzz");
17+
} else {
18+
System.out.printf("%d", index);
19+
}
20+
if (index != repetitions){
21+
System.out.print(", ");
22+
} else {
23+
System.out.println();
24+
}
25+
}
26+
}
27+
}

Diff for: Day1/README.md

+30
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,36 @@ class FizzBuzzPrabhatTest {
149149
}
150150
}
151151
```
152+
### [Solution 3]: (./Java/FizzBuzz_wb.java)
153+
```java
154+
/*
155+
* @author wboccard
156+
* @date October 7, 2020
157+
*/
158+
159+
public class FizzBuzz_wb {
160+
161+
public static void main(String[] args){
162+
int repetitions = 50;
163+
for (int index = 1; index <= repetitions; index++){
164+
if (index % 3 == 0 && index % 5 == 0){
165+
System.out.print("FizzBuzz");
166+
} else if (index % 3 == 0){
167+
System.out.print("Fizz");
168+
} else if (index % 5 == 0){
169+
System.out.print("Buzz");
170+
} else {
171+
System.out.printf("%d", index);
172+
}
173+
if (index != repetitions){
174+
System.out.print(", ");
175+
} else {
176+
System.out.println();
177+
}
178+
}
179+
}
180+
}
181+
```
152182

153183
## C Implementation
154184

0 commit comments

Comments
 (0)