عرض مشاركة واحدة
منتديات طلاب وطالبات جامعة الملك عبد العزيز منتديات طلاب وطالبات جامعة الملك عبد العزيز
قديم 17-11-2011, 01:57 AM   #27

Prince soma

Super Hussam

الصورة الرمزية Prince soma

 
تاريخ التسجيل: Sep 2011
التخصص: IT
نوع الدراسة: إنتظام
المستوى: الرابع
الجنس: ذكر
المشاركات: 266
افتراضي رد: Cpcs 202 شروحات وحلول وواجبات الجافا

هذا حل السؤال التاسع

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==&& num1%6==0) +
            
            
"\n divisible by 5 or 6? \t " 
            
+ (num1%5==|| num1%6==0) +
            
           
"\n divisible by 5 or 6, but not both? \t  " +
             (
num1%5==num1%6==0));

        
    }

إن شاء الله يكون مفهوم

 

Prince soma غير متواجد حالياً   رد مع اقتباس