import java.io.*; public class Multiples { static BufferedReader keyboard = new BufferedReader (new InputStreamReader (System.in)); static final int PER_LINE = 5; // numbers to print per line public static void main (String[] args) throws IOException { int value, limit, mult, count = 0; // ask the user for the starting value System.out.print ("Enter a positive value: "); value = Integer.parseInt(keyboard.readLine()); // ask the user for the maximum value System.out.print ("Enter an upper limit: "); limit = Integer.parseInt(keyboard.readLine()); System.out.println ("\nThe multiples of " + value + " between " + value + " and " + limit + " (inclusive) are:"); // print the multiples System.out.print("\t"); for (mult = value; mult <= limit; mult += value) { System.out.print (mult + "\t"); // print a specific number of values per line of output count++; if (count % PER_LINE == 0) { System.out.println(); System.out.print("\t"); } } System.out.println(); } }