HERE WE HAVE SOLVED AS PER AS PRIME LOGIC
FOR OTHER NUMBERS FOLLOW THE NUMBER FINDING LOGIC
FROM HERE - https://javaeasycodings.blogspot.com/p/programs-number-findings-basics.html
BUT THE LOGIC MUST BE SAME
import java.util.*;
class REPLACE_BY_ZERO
{
void main()
{
Scanner sc=new Scanner(System.in);
int a[]=new int[10],i,j,c;
System.out.println("Enter 10 numbers:");
for(i=0;i<10;i++)
a[i]=sc.nextInt();
for(i=0;i<10;i++)
{
c=0;
for(j=1;j<=a[i];j++)
{
if(a[i]%j==0)
c++;
}
if(c>2)
a[i]=0;
}
System.out.println("Modified Array:");
for(i=0;i<10;i++)
{
System.out.print(a[i]+" ");
}
}
}