FizzBuzz

 import java.util.*;


public class fizzbuzz {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        System.out.println("Enter the number");

        int n = sc.nextInt();

        String result = (n % 3 == 0 && n % 5 == 0) ? "fizzbuzz" :(n % 5 == 0) ? "buzz" :(n % 3 == 0) ? "fizz15" : Integer.toString(n);

        System.out.println(result);
    }
}

Comments

Popular posts from this blog

Convert first letter to capital letter in java

Stair case traversal search

Palindrome of string my logic