diff --git a/java/FizzBuzzMap.java b/java/FizzBuzzMap.java new file mode 100644 index 0000000..9a80191 --- /dev/null +++ b/java/FizzBuzzMap.java @@ -0,0 +1,24 @@ +import java.util.HashMap; +import java.util.TreeMap; + +public class FizzBuzzMap{ + + public static void main(String []args) { + HashMap fizzBuzzTreeMap = new HashMap(); + for (int i = 1; i <= 100; i++) { + if (i % 5 ==0 && i % 3 == 0) { + fizzBuzzTreeMap.put(i, "FizzBuzz"); + } else if (i % 5 == 0) { + fizzBuzzTreeMap.put(i, "Buzz"); + } else if (i % 3 ==0) { + fizzBuzzTreeMap.put(i, "Fizz"); + } else { + fizzBuzzTreeMap.put(i, String.valueOf(i)); + } + } + + for (int i = 1; i <= 100; i++) { + System.out.println(fizzBuzzTreeMap.get(i)); + } + } +} \ No newline at end of file