232,768 views
0 votes
0 votes
Create a program that will prompt the user

for a string and a positive integer n. The program should output the
string to the screen n times, as shown below.
Enter message: "I love computers"
Enter n: 5
I love computers
I love computers
I love computers
I love computers
I love computers

User Graykos
by
2.7k points

1 Answer

15 votes
15 votes

Answer:

using java programming language;

.

.

import java.util.Scanner;

public class Echo {

public static void main(String[] args) {

String message; int n;

Scanner in = new Scanner(System.in);

System.out.print("Enter your message: ");

System.out.print(" Enter n times");

message= in.nextLine();

System.out.println( line*n);

}

Step-by-step explanation:

The System class also provides the special value System.in, which is an InputStream

that provides methods for reading input from the keyboard

User Julius Babies
by
2.8k points