-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFizzBuzz.java
More file actions
57 lines (33 loc) · 1.07 KB
/
Copy pathFizzBuzz.java
File metadata and controls
57 lines (33 loc) · 1.07 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
import javax.swing.JOptionPane;
// Copyright Wintriss Technical Schools 2013
/**
* Fizz Buzz
*
* In this project, we're going to build FizzBuzz. It's a children's game where
* you count from 1 to 20. Easy, right? Here's the catch: instead of saying
* numbers divisible by 3, say "Fizz". And instead of saying numbers divisible
* by 5, say "Buzz". For numbers divisible by both 3 and 5, say "FizzBuzz".
*
* So the rules are:
* Any number divisible by 3 is replaced by the word fizz
* Any number divisible by 5 is replaced by the word buzz.
* Numbers divisible by both 3 and 5 become fizzbuzz.
*
* Print your results to the console, or using JOptionPane if you like.
**/
public class FizzBuzz {
public static void main(String[] args) {
for (int i=1; i<40; i++) {
if (i%5==0&&i%3==0) {
JOptionPane.showMessageDialog(null, "FizzBuzz!");
}
else if (i%3==0) {
JOptionPane.showMessageDialog(null, "Fizz!");
}
else if (i%5==0) {
JOptionPane.showMessageDialog(null, "Buzz!");
}
else {
JOptionPane.showMessageDialog(null, i);
}
}}}