题目:
( 使用操作符&&、 ‖ 和∧) 编写一个程序,提示用户输入一个整数值,然后判定它是否
能被 5 和 6 整除,是否能被 5 或 6 整除,以及是否能被 5 或 6 整除但是不能同时被它们
整除。 下面是这个程序的运行示例:
Enter an integer: 10
Is 10 divisible by 5 and 6 ? false
Is 10 divisible by 5 or 6 ? true
Is 10 divisible by 5 or 6, but not both ? true
class Tang_01_19
{
public static void main(String[] args)
{
Scanner input=new Scanner(System.in);
int a1=0,a2=0,a3=0;
System.out.print("Enter an integer: ");
int integer=input.nextInt();
System.out.print("is "+integer+"divisible by 5 and 6? ");
System.out.println(integer%5==0&&integer%6==0);
System.out.print("is "+integer+"divisible by 5 or 6? ");
System.out.println(integer%5==0||integer%6==0);
System.out.print("is "+integer+"divisible by 5 or 6, but not both ? ");
System.out.println(integer%5==0^integer%6==0);
}
}