write a program to check whether the number is three digit special number or not in java programing
Answers
Answered by
9
CODE :
import java.util.*;
class check
{
public void main()
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter a number");
int n=sc.nextint();
int s=0;
int d=0;
int cpy=n;
if(n>99&&n<=999)
{
while(n>0)
{
d=n%10;
s=s+d;
n=n/10;
}
if(s==cpy)
{
System.out.println("Perfect number");
}
else
{
System.out.println("Not a perfect number");
}
}
else
{
System.out.println("Invalid choice entered");
}
}//main ends
}//class ends
-----------------------------
Hope it helps you dear !!
_________________________________
Similar questions