Question: Write a program in java that prompts the user for a number n and prints out the numbers from 1 to n (inclusive), one per

Write a program in java that prompts the user for a number n and prints out the numbers from 1 to n (inclusive), one per line. If the number is evenly divisible by 3, print the word fizz after the number. If the number is evenly divisible by 5, print the word buzz after the number. If the number is evenly divisible by both 3 and 5, it will be followed by both fizz and buzz. Below is an example. Note: if the user enters a value for n that is less than 1, print the message

Error: n must be at least one.

What is the value of n? 16

1

2

3 fizz

4

5 buzz

6 fizz

7

8

9 fizz

10 buzz

11

12 fizz

13

14

15 fizz buzz

16

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!