Wednesday, 5 June 2013

Extra efforts increases complexity but still
A program to check divisibility by 3,5,7
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
class Divi{
public static void main(String arg[])
{
System.out.println("press 1 to check divi by 3");
System.out.println("press 2 to check divi by 5");
System.out.println("press 3 to check divi by 7");
int a;
a=Integer.parseInt(arg[0]);
int b;
b=Integer.parseInt(arg[1]);
System.out.println("enter the number to be checked");
switch (a)
{

case 1:
if (b%3==0)
{
System.out.println("no is divi by 3");
}
else{
System.out.println("it is not divi");
}
break;
case 2:
if (b%5==0)
{
System.out.println("it is divi by 5");}
else{
System.out.println("it is not divi");
}
break;
case 3:
if (b%7==0){
System.out.println("it is divi by 7");}
else{
System.out.println("it is not divi by 7");
}
break;
}
}
}
]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]

No comments:

Post a Comment