Java Programming @ little drops @

News Android Apps

USA,UK,India and Technology News Android App

view more

Programming Android Apps

Java,Java Programming,Unix and Linux Guide

view more

More Programming

Easy Concepts and More Programming

C++ view more

Example Program For Armstrong Number In Java

Armstrong Number Explanation:

The Armstrong numbers from 0 to 10000 are 1,153, 370, 371, 407!!

That's it Nothing more and nothing less ;) 
Let k be the number of digits in a number, n, and d1,d2,d3,d4... be the digits of n.
Say n=370. Then k=3 and d1=3, d2=7 and d3=0.
Now 33+73+03=370. So 370 is an Armstrong number.

Armstrong iff n=d1k+d2k+d3k+d4k+...

Example Program For Armstrong Number In Java:

// Example Program for Find Armstrong Number In Java Programmming


class ArmstrongExample {

    public static void main(String args[]) throws IOException {
        int number, sum = 0, temp, remainder;

        BufferedReader br = new BufferedReader(new InputStreamReader(;
        System.out.println("Enter a Number :");
        number = Integer.parseInt(br.readLine());

        temp = number;

        while (temp != 0) {
            remainder = temp % 10;
            sum = sum + remainder * remainder * remainder;
            temp = temp / 10;

        if (number == sum) {
            System.out.println("Entered number is an Armstrong Number.");
        } else {
            System.out.println("Entered number is not an Armstrong Number.");

Sample Output:

Enter a Number :
Entered number is an Armstrong Number.

Enter a Number :
Entered number is not an Armstrong Number.


Information and Search