Question
When the provided integer n is divisible by 3, print fizz. When the provided integer is divisible by 5, print buzz. When it is divisible
When the provided integer n is divisible by 3, print fizz. When the provided integer is divisible by 5, print buzz. When it is divisible by both 3 and 5, print fizzbuzz. Otherwise print the integer.
Use the Boolean variables fizz and buzz in the conditions.
import java.util.Scanner;
public class FizzBuzz { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); boolean fizz = n % 3 == 0; boolean buzz = n % 5 == 0; if (/* Your code goes here */) { System.out.print("fizz"); } if (/* Your code goes here */) { System.out.print("buzz"); } if (/* Your code goes here */) { System.out.print(n); }
System.out.println(); } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started