import java.io.*; import java.util.Scanner; public class Multiples { 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; Scanner scan = new Scanner(System.in); // ask the user for the starting value System.out.print ("Enter a positive value: "); value = scan.nextInt(); // ask the user for the maximum value System.out.print ("Enter an upper limit: "); limit = scan.nextInt(); 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(); } }