Skip to content

Instantly share code, notes, and snippets.

@213edu
Last active August 29, 2015 14:06
Show Gist options
  • Save 213edu/d7a2ac459414cce7ede0 to your computer and use it in GitHub Desktop.
Save 213edu/d7a2ac459414cce7ede0 to your computer and use it in GitHub Desktop.
import java.util.Scanner;
/**
* Created by Ryan on 9/21/2014.
*/
public class NumDetails {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int value;
System.out.println("Enter an Integer:");
value = input.nextInt();
// even
if (value % 2 == 0){
if (value % 5 == 0 && value % 6 == 0){
System.out.println("The number " + value + " is even and is divisible by 5 and 6.");
} else if (value % 5 == 0 && value % 6 != 0) {
System.out.println("The number " + value + " is even and is divisible by 5 but not 6.");
} else if (value % 6 == 0 && value % 5 != 0){
System.out.println("The number " + value + " is even and is divisible by 6 but not 5");
} else if (value % 5 != 0 && value % 6 != 0){
System.out.println("The number " + value + " is even and is not divisible by 5 or 6");
}
} else {
// odd
if (value % 5 == 0 && value % 6 == 0){
System.out.println("The number " + value + " is odd and is divisible by 5 and 6.");
} else if (value % 5 == 0 && value % 6 != 0) {
System.out.println("The number " + value + " is odd and is divisible by 5 but not 6.");
} else if (value % 6 == 0 && value % 5 != 0){
System.out.println("The number " + value + " is odd and is divisible by 6 but not 5");
} else if (value % 5 != 0 && value % 6 != 0){
System.out.println("The number " + value + " is odd and 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