import java.io.*;
abstract class base
{
int a[]=new int[10];
abstract void cal();
}
class derived extends base
{
int i,j,b=0,n;
public void get()
{
try
{
DataInputStream cin=new DataInputStream(System.in);
System.out.println("Enter matrix size");
n=Integer.parseInt(cin.readLine());
System.out.println("Enter the first matrix");
for(i=0;i<n;i++)
{
a[i]=Integer.parseInt(cin.readLine());
}
}
catch(Exception e)
{
System.out.println("wrong data");
}
}
public void cal()
{
for(i=0;i<n;i++)
{
for(j=2;j<a[i];j++)
{
if(a[i]%j==0)
{
b=0;
break;
}
else
{
b=1;
}
}
if(b==1)
{
System.out.println(a[i]+" is prime");
}
}
}
}
class abs_arr_prime
{
public static void main(String args[])
{
derived d=new derived();
d.get();
d.cal();
}
}
abstract class base
{
int a[]=new int[10];
abstract void cal();
}
class derived extends base
{
int i,j,b=0,n;
public void get()
{
try
{
DataInputStream cin=new DataInputStream(System.in);
System.out.println("Enter matrix size");
n=Integer.parseInt(cin.readLine());
System.out.println("Enter the first matrix");
for(i=0;i<n;i++)
{
a[i]=Integer.parseInt(cin.readLine());
}
}
catch(Exception e)
{
System.out.println("wrong data");
}
}
public void cal()
{
for(i=0;i<n;i++)
{
for(j=2;j<a[i];j++)
{
if(a[i]%j==0)
{
b=0;
break;
}
else
{
b=1;
}
}
if(b==1)
{
System.out.println(a[i]+" is prime");
}
}
}
}
class abs_arr_prime
{
public static void main(String args[])
{
derived d=new derived();
d.get();
d.cal();
}
}
No comments:
Post a Comment