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.
Functional decomposition
Checking divisibility and printing appropriate strings
Report a typo
Sample Input 1:
3Sample Output 1:
FizzSample Input 2:
5Sample Output 2:
BuzzWrite 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
}
___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.