标签:
1 import java.util.Scanner; 2 3 public class Solution 4 { 5 public static void main(String[] args) 6 { 7 Scanner input = new Scanner(System.in); 8 9 System.out.print("Enter an integer: "); 10 int number = input.nextInt(); 11 12 input.close(); 13 14 System.out.print("Is " + number + " divisible by 5 and 6? "); 15 if(number % 5 == 0 && number % 6 == 0) 16 System.out.println("true"); 17 else 18 System.out.println("false"); 19 20 System.out.print("Is " + number + " divisible by 5 or 6? "); 21 if(number % 5 == 0 || number % 6 == 0) 22 System.out.println("true"); 23 else 24 System.out.println("false"); 25 26 System.out.print("Is " + number + " divisible by 5 or 6, but not both? "); 27 if(number % 5 == 0 ^ number % 6 == 0) 28 System.out.println("true"); 29 else 30 System.out.println("false"); 31 } 32 }
标签:
原文地址:http://www.cnblogs.com/wood-python/p/5767287.html