Question: Write a program that uses a loop to print the integers 1 to 100, one number on each line. When a number is divisible by

Write a program that uses a loop to print the integers 1 to 100, one number on each line. When a number is divisible by 3, print "Blue" on the same line, and separate them by a space. When a number is divisible by 5, print "Berry"; and when a number is divisible by 15, print "Blueberry".

Note that a number divisible by 15 will also be divisible by 3 and 5. In this case, only "Blueberry" should be printed.

Provide an input form that accepts a number n that determines how many times the loop should iterate (100 in the example above). The form should also allow the end-user to enter any two words to display and concatenate (e.g., "Blue" and "Berry" above).

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!