Weity a prograyn in java to accept a number and find the sum of its digits. The program
also checks whether the sum of the digits is a prime number or not and displace an appropriate mmessage
please answer soon it's urgent
Answers
Answered by
3
Answer:
import java.util.*;
public class abc {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter A Number");
int a = sc.nextInt();
int sum = 0, dig = 0;
while (a > 0)
{
dig = a%10;
sum=sum+dig;
a=a/10;
}
System.out.println("sum = "+sum);
}
}
Similar questions