/**
 * PrintMultiplesWithErrorChecking
 *
 * Uses a while loop to print all multiples of a number less than 100,
 * and ensures that the user enters a positive integer.
 *
 * Computer Science S-111
 */

import java.util.Scanner;

public class PrintMultiplesWithErrorChecking {
    public static void main(String[] args) {
        Scanner console = new Scanner(System.in);
        int num;

        // Keep prompting until the user enters a positive integer.
        //
        // This way involves some code duplication:
        //   System.out.print("Enter a positive integer: ");
        //   num = console.nextInt();
        //   while (num <= 0) {
        //       System.out.print("Enter a positive integer: ");
        //       num = console.nextInt();
        //   }
        //
        // Using a do-while loop allows us to avoid the duplication.
        do {
            System.out.print("Enter a positive integer: ");
            num = console.nextInt();
        } while (num <= 0);
                
        System.out.println("\nThe multiples of " + num +
          " less than 100 are:");
                
        int mult = num;
        while (mult < 100) {
            System.out.print(mult + " ");
            mult = mult + num;
        }
                
        System.out.println();
    }
}
