Java Bootcamp – Workbooks and Challenges
)}

Workbook 5.7

From Java Bootcamp Resources -> Module 1 -> 5. Loops, open Workbook 5.7.

Fizz Buzz

Your program has to print numbers from 0 to 18.

  • If a number is a multiple of three, mark it: Fizz.

  • If a number is a multiple of five, mark it: Buzz.

  • If a number is a multiple of three and five, mark it: FizzBuzz.

Task 1


Make a for loop that counts from 0 to 18 and print each number.

>>: 0
>>: 1
>>: ...
>>: 18

Task 2


Set up an if - else if - else statement.

  • if the number is a multiple of three, mark it: Fizz.

  • if the number is a multiple of five, mark it: Buzz.

  • if the number is a multiple of three and five, mark it: FizzBuzz.

Hints:

  • A number is a multiple of X if number ÷ X results in a remainder of zero.

  • There are three conditions for Fizz, Buzz, and FizzBuzz. Be careful about their order. If something is FizzBuzz, it also satisfies the conditions for Fizz and Buzz.

Good Luck!

Feedback Summary
4.8
38 students
5

92%
4

3%
3

0%
2

0%
1

5%
Written Reviews
There are no written reviews yet.