20) Write a program to input a numbers and check whether it is Fizz or Buzz or FizzBuzz. (n%3=0,fizz|n%7=0,buzz|(n%7=0&n%3=0,fizz buzz))
import java.util.*;public class Fizz_buzz_fizzbuzz_5{public static void main(String args[ ]){Scanner sc = new Scanner (System.in);System.out.println("Enter a number");int a = sc.nextInt();String s = "";if(a%3==0){s = "FIZZ";}else if(a%7==0){s = "BUZZ";}else if(a%7==0&&a%3==0){s = "FIZZBUZZ";}else{s = "nor FIZZ,BUZZ or FIZZBUZZ";}System.out.println("Entered number is "+s);}}
No comments:
Post a Comment
if you have any doubts, Please let me know.
Your Truly
Shashank Porwal