Skip to content

Instantly share code, notes, and snippets.

@karellism
Last active February 15, 2019 08:42
Show Gist options
  • Save karellism/cd25d9a3d8c229e0e741b39abd172384 to your computer and use it in GitHub Desktop.
Save karellism/cd25d9a3d8c229e0e741b39abd172384 to your computer and use it in GitHub Desktop.
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);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment