The Scanner receives the user input. The different variables for appropriate data type is used to store input. The for loop contains the print statement to repeat the message. The helper method takes the message and number and handles printing - using the main to take and store input then call the method.
Here are the steps and instructions:
- Prompt the use to enter a message, read the input (using a Scanner) and store is as a String
- Prompt the user to enter a number and store the input as an int
- Write a for-loop which prints the message the given number of times, by using the given number in the loop condition
- Include a method called repeatMessage. The method should accept a String and an int as parameters, and contain the for-loop that will print the output (move the for loop into this method)
- Call the repeatMessage method from main passing both values (message and number) as parameters
- Experiment with different inputs to ensure your program functions as expected