هذا حل السؤال التاسع
9. (Using the &&, || and ^ operators) Write a program that prompts the user to enter an integer and determines whether it is divisible by 5 and 6, whether it is divisible by 5 or 6, and whether it is divisible by 5 or 6, but not both. For example, if your input is 10, the output should be
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
كود PHP:
import java.util.Scanner;
public class Activity9 {
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
System.out.println("Enter an integer: \t");
int num1=input.nextInt();
System.out.println(" Is " + num1 +
" divisible by 5 and 6? \t "
+ (num1%5==0 && num1%6==0) +
"\n divisible by 5 or 6? \t "
+ (num1%5==0 || num1%6==0) +
"\n divisible by 5 or 6, but not both? \t " +
(num1%5==0 ^ num1%6==0));
}
}
إن شاء الله يكون مفهوم