Answer:
The following are the program in the Java Programming Language.
//define a function
public void dashedLine (int x)
{
//check the variable 'a' is greater than 0
if (x>0)
{
//declare integer data type variable
int i;
//set the for loop that iterates from 1 to variable 'a'
for (i=1;i<=x;i=i+1)
{
//print the following dashes
System.out.print("-");
}
//for empty space
System.out.println("");
}
}
Explanation:
The following are the description of the program.