Computer Science, asked by panshulji, 9 months ago

write a program in java to accept a number and calculate the product of prime digits​

Answers

Answered by anindyaadhikari13
41

Here is your answer.

import java.util.*;

class Program

{

//creating a method to check whether a number is prime or not.

static boolean isPrime(int n)

{

int c=0;

for(int i=1;i<=n;i++)

{

if(n%i==0)

c++;

}

if(c==2)

return true;

else

return false;

}

//main() method.

public static void main()

{

Scanner sc = new Scanner(System.in);

System.out.print("Enter the number: ");

int n=sc.nextInt();

int p=1;

while(n!=0)

{

int d=n%10;

if(isPrime(d)) // check prime.

p=p*d;

n=n/10;

}

System.out.println(" Product of prime digits is: "+p);

}

}

Answered by yashmatalia25
0

Answer:

j ex5ygdcbgcbgf

yutyc

Explanation:

vvvv

Similar questions