Examlex

Solved

Programming Write a Static Method Hopscotch That Shows a Sequence of of Numbers

question 7

Essay

Programming
Write a static method hopscotch that shows a sequence of numbers similar to the appearance of a hopscotch board. (Hopscotch is a "hopping" game played by children.) For this problem, a hopscotch board is an increasing sequence of numbers in lines in an alternating pattern. Odd lines contain a single number indented by 3 spaces. Even lines contain a pair of numbers with the first number not indented, followed by 5 spaces, followed by the second number.
Your method should accept a parameter representing the number of "hops" worth of numbers to display. A board of 0 "hops" shows only the number 1, indented by 3 spaces. A "hop" is defined as a trio of additional numbers spread across 2 additional lines, following the pattern described previously. So for example, 1 hop means to show the numbers 2-3-4 to the board in the pattern shown below. 2 hops means to show the numbers 2-3-4, 5-6-7 on the board. 3 hops means to show 2-3-4, 5-6-7, 8-9-10, and so on. Assume that the number of hops passed will be at least 0.
Here are some example calls to the method and their resulting console output:
Programming Write a static method hopscotch that shows a sequence of numbers similar to the appearance of a hopscotch board. (Hopscotch is a  hopping  game played by children.) For this problem, a hopscotch board is an increasing sequence of numbers in lines in an alternating pattern. Odd lines contain a single number indented by 3 spaces. Even lines contain a pair of numbers with the first number not indented, followed by 5 spaces, followed by the second number. Your method should accept a parameter representing the number of  hops  worth of numbers to display. A board of 0  hops  shows only the number 1, indented by 3 spaces. A  hop  is defined as a trio of additional numbers spread across 2 additional lines, following the pattern described previously. So for example, 1 hop means to show the numbers 2-3-4 to the board in the pattern shown below. 2 hops means to show the numbers 2-3-4, 5-6-7 on the board. 3 hops means to show 2-3-4, 5-6-7, 8-9-10, and so on. Assume that the number of hops passed will be at least 0. Here are some example calls to the method and their resulting console output:


Definitions:

Snippet

A small portion or extract from a larger text or data set, typically used for quoting or programming code examples.

Block The Sender

A feature in email and messaging services used to prevent further messages from a specific source.

Default Reminder Time

The preset time period before an event when a reminder notification is automatically sent or displayed.

Incoming Mail Server

A server that receives and stores email messages sent to a user, allowing them to download or view the messages later using an email client.

Related Questions