Source of DivByFive.java


  2: import java.util.Scanner;

  4: public class DivByFive {

  6:     public static final int DIV = 5;

  8:     public static void main(String[] args) {
  9:         // create the variables
 10:         Scanner kbd = new Scanner(System.in);
 11:         int num;

 13:         // read several positive numbers...
 14:         System.out.println("Enter some numbers below: ");
 15:         num = kbd.nextInt();
 16:         while (num >= 0) {
 17:             // report whether each is divisible by DIV
 18:             if (num % DIV == 0) {
 19:                 System.out.println(num + " is divisible by " + DIV + ".");
 20:             } else {
 21:                 System.out.println(num + " is not divisible by " + DIV + ".");
 22:             }
 23:             num = kbd.nextInt();
 24:         }
 25:         kbd.nextLine();
 26:     }

 28: }