Make a Java program....
Answers
Answer:
import java.util.Scanner;
class SpecialNumber
{
public static void main(String[] args)
{
//Declaration
Scanner input = new Scanner(System.in);
int n, sum, product;
int temp, digit;
//Prompt and accept a number from user
System.out.println("Enter a number: ");
n = input.nextInt();
//Initialization
sum = 0;
product = 1;
temp = n;
//Loop to extract each digit and calculate its sum
for (int i = 1; i <= n; i++)
{
digit = n % 10;
sum = digit + sum;
product = digit * product;
n = n/10;
}
if (temp == (sum + product))
{
System.out.println(temp + " is a special number");
}
else
{
System.out.println(temp + " is not a special number");
}
}
}