Tuesday, February 18

Finding Common Divisor using Conditional Operators in Java



Hi ALL,

Here I wrote a program for Finding Common Divisor using Conditional Operators in Java.




/**
 *
 * @author Balamurgan M
 */
import java.util.Scanner;

public class OperatorExample {
    public static void main(String arg[]){
        System.out.println("Please enter number :");
        Scanner in=new Scanner(System.in);
        int num=in.nextInt();
        if(((num %2 )==0)&&((num%3)==0))
            System.out.println(" Given number divisional by 2 and 3 "+num);
        else if(((num %2 )==0)||((num%3)==0))
             System.out.println(" Given number divisional by 2 or 3 "+num);
        else if (!((num %2 )==0)||((num%3)==0))
                System.out.println(" Given number Not divisional by 2  3 "+num);
    }
}

No comments:

Post a Comment

Backup files to google drive using PHP coding

 Dear All, To backup files to Google Drive using PHP coding, you can use the Google Drive API and the Google Client Library for PHP. Here...