Answer:
Following are the program in the Java Programming Language.
public class Main // declared class
{
public void hopscotch(int x) // function definition
{
int count=0; // variable declaration
for (int j=0; j<x; j++) // iterating over the loop
{
System.out.println(" " + (++count)); // print the value of count
System.out.println((++count) + " " + (++count));
}
System.out.println(" " + (++count));
}
public static void main(String[] args) // main method
{
Main ob=new Main(); // creating object
ob.hopscotch(3); // calling hopscotch method
}
}
Output:
1
2 3
4
5 6
7
8 9
10
Explanation:
Here, we define a class "Main" and inside the class, we define a function "hopscotch()" and pass an integer type argument in its parentheses and inside the function.