karellism
1/15/2019 - 3:53 PM

Divisible by 7 in Java

TRUE or FALSE is Divisible by 7?

/******************************************************************************
 *
 *  Reads in two integer command-line arguments x and y and prints "true"
 *  if both are divisible by 7, and false otherwise.
 *
 *  a % 7 is the remainder when you divide 7 into a. If the remainder
 *  is 0, then a is divisible by 7.
 *
 ******************************************************************************/

public class Divisibility {
    public static void main(String[] args) {
        int x = Integer.parseInt(args[0]);
        int y = Integer.parseInt(args[1]);
 
        boolean isDivisible = (x % 7 == 0) && (y % 7 == 0);

        System.out.println(isDivisible);
    }