-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
30 lines (25 loc) · 839 Bytes
/
Main.java
File metadata and controls
30 lines (25 loc) · 839 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import java.util.Scanner;
public class Main {
public static void main(String[] args)
{
try (// Scanner to receive the input
Scanner scanner = new Scanner(System.in)) {
// Prompts the user to enter a message
System.out.println("Please input a message: ");
String message = scanner.nextLine();
// Prompts the user to enter a number
System.out.println("Please input a number: ");
int number = scanner.nextInt();
// calling the repeatMessage method
// call the parameters here from the repeatMessage method
repeatMessage(message, number);
}
}
// method that repeats the message the given number of times
public static void repeatMessage(String message, int number) {
for (int i = 0; i < number; i++)
{
System.out.println(message);
}
}
}