Last active
October 5, 2015 18:19
-
-
Save jonathan-irvin/1412cdad3ea1920b81fa to your computer and use it in GitHub Desktop.
Divisible by 5 or 6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
public class Divby5or6 { | |
public static void main(String[] args) { | |
System.out.print("Enter A Number: "); | |
Scanner input = new Scanner(System.in); | |
int number = input.nextInt(); | |
boolean divisibleBy5 = (number % 5 == 0); | |
boolean divisibleBy6 = (number % 6 == 0); | |
if((divisibleBy5 && !(divisibleBy6)){ | |
System.out.print(number + " is divisible by 5, but not 6"); | |
}else if((divisibleBy6) && !(divisibleBy5)){ | |
System.out.print(number + " is divisible by 6, but not 5"); | |
}else if (divisibleBy5 && divisibleBy6){ | |
System.out.print(number + " is divisible by 5 and 6."); | |
}else if (!(divisibleBy5) && !(divisibleBy6)) { | |
System.out.print(number + " is not divisible by 5 or 6."); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment