Skip to content

Commit

Permalink
CT_340
Browse files Browse the repository at this point in the history
  • Loading branch information
Jade-Good committed Dec 20, 2024
1 parent afaa01c commit 871e1a2
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions BOJ/Java/src/B1/Boj_28702_FizzBuzz.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package B1;

import java.io.*;

public class Boj_28702_FizzBuzz {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

int next = -1;

for (int i = 3; i > 0; i--) {
String s = br.readLine();
if (Character.isDigit(s.charAt(0))) {
next = Integer.parseInt(s) + i;
break;
}
}

if (next % 5 == 0 && next % 3 == 0) {
bw.write("FizzBuzz");
} else if (next % 5 != 0 && next % 3 == 0) {
bw.write("Fizz");
} else if (next % 5 == 0) {
bw.write("Buzz");
} else {
bw.write(Integer.toString(next));
}
bw.flush();
}
}

0 comments on commit 871e1a2

Please sign in to comment.