A dazzling Armstrong Number Program
Armstrong Number Program: solved Java program for ICSE Class 9 Computer Applications with complete BlueJ code, explanation and sample output.
It is a number that is equal to the sum of cubes of its digits. For example 153
1^3+5^3+3^3=1+125+27=153.
For some basic concepts of java visit the link.
Conditional Constructs in JAVA
Write a program to accept a number and check whether it is an Armstrong number or not.
import java.io.*;
public class ArmstrongNumber //number = the sum of the cubes of the digits e.g., 153
{
public static void main() throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter a number");
int num=Integer.parseInt(br.readLine());
int n=num;
int sum=0;
while(num!=0)
{
int rem=num%10;
rem=(int)Math.pow(rem,3);
sum+=rem;
num=num/10;
}
if(sum==n)
{
System.out.println("Armstrong number");
}
else
{
System.out.println("Not an Armstrong number");
}
}
}Output:
Enter a number
153
Armstrong number
Learn the basic concept of java https://youtu.be/TRm9r4gFTho
Related Posts
Continue learning with these related articles

String Methods in Java for ICSE Class 10: 25 Output Questions with Answers
ICSE Class 10 Computer Applications practice on String class methods: length, charAt, indexOf, lastIndexOf, substring, replace, trim, compareTo, equals and more, with 25 board-style output questions and step-by-step answers.

Special Number Programs in Java for ICSE: Armstrong, Spy, Neon, Disarium, Pronic and More
Every special number asked in ICSE Computer Applications – prime, perfect, Armstrong, palindrome, automorphic, neon, spy, Niven, duck, buzz, Disarium, special and pronic numbers – with definitions, examples and one complete Java program that checks them all.

Math Library Methods in Java for ICSE Class 9 (with Outputs)
ICSE Class 9 Computer Applications notes on the Java Math class: sqrt, cbrt, pow, abs, max, min, ceil, floor, round, rint and random, with return types, tricky negative-number outputs and Java expressions for formulas.