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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!