Question: For this assignment, you will take a message and a number from the user as input, and print the given message the specified number of

For this assignment, you will take a message and a number from the user as input, and print the given message the specified number of times. You will need to use a Scanner to receive input, use variables of the appropriate data type to store input, and use a for loop containing a print statement to repeat the message. You should use a helper method which takes the message and number and handles the printing, using main to take and store input then call the method.
Steps:
Prompt the user to enter a message, read the input (using a Scanner) and store it 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 you made to 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

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!