216k views
1 vote
#In the previous coding problem, you created a function #called hide_and_seek that printed the numbers from 1 to 10. #Now, however, we want to extend that. What if we want to #count to 20? 30? # #Modify your previous function so that it takes as input one #parameter: count. Then, instead of printing the numbers from #1 to 10, it should print the numbers from 1 to the value of #count. Then, end with "Ready or not, here I come!"

User JWBG
by
6.3k points

1 Answer

4 votes

Answer:

public class num7 {

//Method hide and seek begins here

public static void hide_and_seek(int count){

for(int i=1; i<=count; i++){

System.out.println(i);

}

System.out.println("Ready or not, here I come!");

}

//Main method begins here

public static void main(String[] args) {

hide_and_seek(20);

hide_and_seek(10);

}

}

Step-by-step explanation:

Using Java programming langauge.

Method hide_and_seek is created with return type void and receives one parameter count

The method uses a for loop to print numbers from 1 to count, then the string Ready or not, here I come!"

In the main method hide_and_seek () is called twice and passed the argument of 20 and 10

User Balfour
by
5.7k points