### PART-B

#### 1

```
```

1. Write a Java program to display only those multi-digit prime numbers between a given range whose digit sum is prime. Display the prime number and its digit sum side by side. Read the value for the range using readLine() method of BufferedReader class.
Sample output:
If range is; m = 20, n=50
Prime number Sum of digits
23 -5
29-11
41-5
43-7
47-11
PROGRAM:

import java.io.IOException;
public class SumandCheckp1{

int m ,n,i;
try{
System.out.println("Enter Start Range M: ");
System.out.println("Enter End Range N: ");

for (i=m;i< n;i++){

checkPrime(i);
}
}catch(Exception e){}
}

static void checkPrime(int value)
{
int i,m=0,flag=0,primetemp=0;
int sum=0;

int temp=value;

while(temp>0)
{
sum=sum+temp%10;
temp=temp/10;
}

primetemp=value;

m=primetemp/2;
if(primetemp==0||primetemp==1)
{
flag=0;
// System.out.println(n+" is not prime number");
}
else
{
for(i=2;i<=m;i++){
if(primetemp%i==0){
// System.out.println(n+" is not prime number");
flag=1;

break;
}
}

if(flag==0)  {
System.out.println(value+" = "+sum+" ");
}
}
}
public static void main(String args[]){