write a program to print the given name for 10 times
Answers
Answered by
0
Answer:
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter a name : ");
String name = sc.nextLine();
for(int i = 0; i < 10; i++) {
System.out.println(name);
}
}
}
Explanation:
- We are accepting a name from the user using the Scanner class.
- Then we have created a for-loop, which would loop through 0-9 (10 iterations) and print the name.
Answered by
0
Answer:
import java.util.*;
class Print
{
public static void main(String args[])
{
Scanner sc= new Scanner(System.in);
System.out.println("Enter a name:");
String name= sc.nextLine();
for(int i=1; i<=10; i++)
{
System.out.println(name);
}
}
}
Similar questions