Write a method called hopscotch that accepts an integer number of hops as its parameter and prints

Question:

Write a method called hopscotch that accepts an integer number of “hops” as its parameter and prints a pattern of numbers that resembles a hopscotch board. A “hop” is a three-number sequence where the output shows two numbers on a line, followed by one number on its own line. 0 hops is a board up to 1; one hop is a board up to 4; two hops is a board up to 7; and so on. For example, the call of hopscotch(3); should print the following output:

2 3 5. 6. 8 9. 10 4.

A call of hopscotch(0); should print only the number 1. If it is passed a negative value, the method should produce no output.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: