&& || ^ 且 或 异或

import java.util.*;
import javax.swing.*;  
  class Main {
    public static void main(String[] args){
      Scanner input = new Scanner(System.in);
      System.out.print("Enter an integer: ");
      int number = input.nextInt();
       
      System.out.print("Is 10 divisible by 5 and 6? " 
                       + ((number % 5 == 0) && (number % 6 == 0)) + "\n");
      System.out.print("Is 10 divisible by 5 or 6? " 
                       + ((number % 5 == 0) || (number % 6 == 0)) + "\n");
      System.out.print("Is 10 divisible by 5 or 6, but not both? " 
                       + ((number % 5 == 0) ^ (number % 6 == 0)) + "\n");

    }
  }
posted @ 2022-05-15 22:54  Scenery_Shelley  阅读(363)  评论(0)    收藏  举报