Computer Science, asked by sornapudivgsuparnaku, 5 hours ago

write a program to print the given name for 10 times​

Answers

Answered by RedProgrammer
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:

  1. We are accepting a name from the user using the Scanner class.
  2. Then we have created a for-loop, which would loop through 0-9 (10 iterations) and print the name.
Answered by Sanskar260
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