Answer :
Answer:
import java.util.Scanner;
public class CountByAnything
{
public static void main (String args[])
{
int beginning = 5;
int ending = 200;
Scanner s = new Scanner(System.in);
System.out.println("Enter the value to count by:");
int valueToCount = s.nextInt();
int counter = 0;
for(int i = beginning; i <= ending; i += valueToCount)
{
System.out.print(i + " ");
if((counter+1) % 10 == 0)
System.out.println();
counter++;
}
}
}
Explanation:
- Initialize the beginning and ending.
- Loop through the value of ending variable.
- Check if numbers per line is equal to ten and Increment the counter .