In: Computer Science
Write a java program calls the following methods:
a. printStars(): Takes an int (n) as parameter and prints n stars (*) using for loop.
ex.
6
******
Code:
import java.util.Scanner;
public class Main
{
   public static void printStars(int n) //method
   {
       for(int i=0; i<n; i++) //for
loop for run n times
          
System.out.print("*"); //printing n stars.
   }
   public static void main(String[] args)
   {
       Scanner sc = new
Scanner(System.in);
       System.out.print("Enter n value:
"); //prompting the user to enter n value.
       int n = sc.nextInt(); //reading n
value.
       Main.printStars(n); //calling the
method
   }
}

output:

Note: my friend if you have any questions or queries comment below. I am happy to answer your all questions. i will sort out your queries. Thank you my friend.