//Program to %7 and odd
//Program by Ahlam Ansari
import java.io.*;
class OddDiv7
{
public static void main(String ahlam[])
{
int num=Integer.parseInt(ahlam[0]);
boolean varOdd=(num%2!=0)?true:false;
boolean varDiv7=(num%7==0)?true:false;
String s=(varOdd==true && varDiv7==true)?"Both":(varOdd==true?"Only odd":(varDiv7==true?"Div7":"None"));
System.out.println(num+" is " + s);
//System.out.println(varOdd+" \n"+varDiv7);
}
}
/*
C:\Users\Ahlam\Google Drive\My Lectures\Fall\OOPM\Programs>javac OddDiv7.java
C:\Users\Ahlam\Google Drive\My Lectures\Fall\OOPM\Programs>java OddDiv7 21
21 is Both
C:\Users\Ahlam\Google Drive\My Lectures\Fall\OOPM\Programs>java OddDiv7 17
17 is Only odd
C:\Users\Ahlam\Google Drive\My Lectures\Fall\OOPM\Programs>java OddDiv7 14
14 is Div7
C:\Users\Ahlam\Google Drive\My Lectures\Fall\OOPM\Programs>java OddDiv7 24
24 is None
C:\Users\Ahlam\Google Drive\My Lectures\Fall\OOPM\Programs>
*/
//Program by Ahlam Ansari
import java.io.*;
class OddDiv7
{
public static void main(String ahlam[])
{
int num=Integer.parseInt(ahlam[0]);
boolean varOdd=(num%2!=0)?true:false;
boolean varDiv7=(num%7==0)?true:false;
String s=(varOdd==true && varDiv7==true)?"Both":(varOdd==true?"Only odd":(varDiv7==true?"Div7":"None"));
System.out.println(num+" is " + s);
//System.out.println(varOdd+" \n"+varDiv7);
}
}
/*
C:\Users\Ahlam\Google Drive\My Lectures\Fall\OOPM\Programs>javac OddDiv7.java
C:\Users\Ahlam\Google Drive\My Lectures\Fall\OOPM\Programs>java OddDiv7 21
21 is Both
C:\Users\Ahlam\Google Drive\My Lectures\Fall\OOPM\Programs>java OddDiv7 17
17 is Only odd
C:\Users\Ahlam\Google Drive\My Lectures\Fall\OOPM\Programs>java OddDiv7 14
14 is Div7
C:\Users\Ahlam\Google Drive\My Lectures\Fall\OOPM\Programs>java OddDiv7 24
24 is None
C:\Users\Ahlam\Google Drive\My Lectures\Fall\OOPM\Programs>
*/
No comments:
Post a Comment