59.6k views
1 vote
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 Tatik
by
8.6k points

1 Answer

5 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 Paulo Janeiro
by
7.9k points

No related questions found