import java.io.*;
class Autobiographical
{
public static void main(String args[])throws IOException
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter the number: ");
int num = Integer.parseInt(br.readLine());
num = Math.abs(num);
int n = num;
String s = String.valueOf(num);
int digit[] = new int[s.length()];
for(int i = digit.length - 1; i >= 0; i--)
{
digit[i] = n % 10;
n /= 10;
}
boolean status = true;
for(int i = 0; i < digit.length; i++)
{
int count = 0;
for(int j = 0; j < digit.length; j++)
{
if(i == digit[j])
count++;
}
if(count != digit[i])
{
status = false;
break;
}
}
if(status)
System.out.println(num + " is an Autobiographical Number.");
else
System.out.println(num + " is NOT an Autobiographical Number.");
}
}
No comments:
Post a Comment
any problem in any program comment:-