Program to check Autobiographical Number in Java

In this tutorial you will learn about the Program to check Autobiographical Number in Java and its application with practical example.

In this tutorial, we will learn to create a Java Program to check Autobiographical Numbers in Java using Java programming.

Prerequisites

Before starting with this tutorial we assume that you are best aware of the following Java programming topics:

  • Java Operators.
  • Basic Input and Output function in Java.
  • Class and Object in Java.
  • Basic Java programming.
  • If-else statements in Java.
  • For loop in Java.

What is  Autobiographical Number

A number is called An autobiographical number if first digit counts how many zeroes are there in number,and second digit counts number of twos init, and so on. Basically, it counts the frequency of digits from 0 to 9.

Example: 1210 it has 1 zero, 2 ones, 1 two, and 0 threes.

Another way we can calculate autobiographical number find the sum of all digits (2+1+2+0+0) i.e.5, and after that counts the number of digits of the given number i.e. 5.if both are equal. Hence, the number 21200 is an autobiographical number.

Program to check Autobiographical Number in Java

In this our program we will find given number is a Autobiographical number or not in using java programming. We would first declared and initialized the required variables. Next, we would prompt user to input the a number.Later we  find number is Autobiographical number or not let’s have a look at the code.

Output

Autobiographical number

Not a Autobiographical number

In this tutorial we have learn about the Program to check Autobiographical Number in Java and its application with practical example. I hope you will like this tutorial.