Answer:
The answer to this question can be given by program that are as follows
import java.util.*;
//import package for taking input from user.
public class Main //define class
{
public static void main (String ag[] ) //define main function
{
int number;
Scanner input = new Scanner(System.in);
for (int i = 0; i < 5; i ++) //loo for input.
{
System.out.print ("Enter a number between 1 - 30: ");
number = input.nextInt(); //input number by the user.
}
asterisk(); //calling function.
}
public static void asterisk() //defination of function.
{
//body of function.
int n; //local variable.
for (n= 0; n <= 30; n++) //using loop for print asterisk
{
if (n !=0)
//printf used for print value.
System.out.printf("*", n ); //print value.
}
for (n= 0; n <= 30; n++) //using loop for print asterisk
{
if (n !=0)
//printf used for print value.
System.out.printf("*", n ); //print value.
}
for (n= 0; n <= 30; n++) //using loop for print asterisk
{
if (n !=0)
//printf used for print value.
System.out.printf("*", n ); //print value.
}
for (n= 0; n <= 30; n++) //using loop for print asterisk
{
if (n !=0)
//printf used for print value.
System.out.printf("*", n ); //print value.
}
for (n= 0; n <= 30; n++) //using loop for print asterisk
{
if (n !=0)
//printf used for print value.
System.out.printf("*", n ); //print value.
}
}
}
Output:
Enter a number between 1 - 30: 2
Enter a number between 1 - 30: 2
Enter a number between 1 - 30: 1
Enter a number between 1 - 30: 3
Enter a number between 1 - 30: 4
*******************************************************************************
Explanation:
In this program we take 5 time input from the user and print the value in the form of (*) that can be explain in above output section.In that program we use printf method that is also used for print the value.