diff --git a/Java/Fizz.java b/Java/Fizz.java new file mode 100644 index 0000000..1ebd585 --- /dev/null +++ b/Java/Fizz.java @@ -0,0 +1,28 @@ +import java.util.*; +class Fizz +{ + public static void main(String args[]) + { + int n = 10; + + for(int i = 1; i <= n; i++) + { + if(i % 15 == 0) + { + System.out.println("FizzBuzz"+" "); + } + else if(i % 5 == 0) + { + System.out.println("Buzz"+" "); + } + else if(i % 3 == 0) + { + System.out.println("Fizz"+" "); + } + else + { + System.out.println(i+" "); + } + } + } +} diff --git a/Java/FizzBuzz.java b/Java/FizzBuzz.java deleted file mode 100644 index 44d8543..0000000 --- a/Java/FizzBuzz.java +++ /dev/null @@ -1,19 +0,0 @@ -public class FizzBuzz -{ - public static void main(String[] args) { - StringBuilder builder = new StringBuilder(); - for(int i=1;i<=100;i++) - { - if(i%3==0 && i%5==0) - builder.append("FizzBuzz, "); - else if(i%3==0) - builder.append("Fizz, "); - else if(i%5==0) - builder.append("Buzz, "); - else - builder.append(i + ", "); - } - builder.deleteCharAt(builder.length()-1); - System.out.println(builder.toString()); - } -}