import java.util.Scanner; /** Demo the use of assert. Also, Java's modulus/remainder operator. @author Jed Yang, 2017-04-05 Try some negative inputs, get confused, then run this with java -ea AssertDemo and try those negative inputs again. https://docs.oracle.com/javase/8/docs/technotes/guides/language/assert.html#usage-invariants */ public class AssertDemo { public static void main(String[] args) { System.out.print("Positive integer, please: "); Scanner kb = new Scanner(System.in); int number = kb.nextInt(); if (number % 3 == 0) { System.out.println("Multiple of three."); } else if (number % 3 == 1) { System.out.println("Multiple of three, plus 1."); } else { assert number % 3 == 2 : number % 3; System.out.println("Multiple of three, plus 2."); } } }