&& || ^
作者:互联网
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");
}
}
标签:10,divisible,number,System,&&,print,out 来源: https://www.cnblogs.com/doudou-20123/p/16275131.html