Checking divisibility and printing appropriate strings

Report a typo

Write a Java program that takes an integer as an input. If the number is divisible by 3, it should print 'Fizz', and if it's divisible by 5, it should print 'Buzz'. If it's divisible by both 3 and 5, print 'FizzBuzz'. For any other integer, just print 'None'. You need to create separate methods to check divisibility by 3, 5 and both.

Sample Input 1:

3

Sample Output 1:

Fizz

Sample Input 2:

5

Sample Output 2:

Buzz
Write a program in Java 17
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int num = scanner.nextInt();

// function calls of isDivByThree, isDivByFive, isDivByThreeAndFive will be here
}
// function isDivByThree will be here

// function isDivByFive will be here

// function isDivByThreeAndFive will be here
}
___

Create a free account to access the full topic