Computer Science, asked by shivanshusharma14022, 9 months ago

If you don't know the answer don't reply I will give extra points if you answer correctly it is to be written in java.dont ask silly questions or say that you don't know the answer. points will be given in any other waste question.(class 10 ICSE)

You have to use only 2 if statement. please give the complete solution don't give only the logic I want complete answer

Input an integer and display Fizz, Buzz, FizzBuzz according to the following criteria:

divisible by 3 -> Fizz

divisible by 5 -> Buzz

divisible by 3 and 5 -> FizzBuzz if none of the above -> display the number

Answers

Answered by masattarsunnyoyp7ov
1

import java.util.*;

class FizzBuzz

{

public static void main(String args[])

{

int n = 100;

// loop for 100 times

for (int i=1; i<=n; i++)

{

if (i%15==0)

System.out.print("FizzBuzz"+" ");

// number divisible by 5, print 'Buzz'

// in place of the number

else if (i%5==0)

System.out.print("Buzz"+" ");

// number divisible by 3, print 'Fizz'

// in place of the number

else if (i%3==0)

System.out.print("Fizz"+" ");

// number divisible by 15(divisible by

// both 3 & 5), print 'FizzBuzz' in

// place of the number

else // print the numbers

System.out.print(i+" ");

}

}

}

Similar questions