Algorithm for Armstrong Number with in Range:
step 1:Read range
step 2: Set count=0, b= 1
step 3: Repeat through step-11 while b less than or equals to range
step 4: Set sum=0
step 5: Set c=b
step 6: Repeat through step-9 while c greater than 0
step 7: a=c%10
step 8: sum=sum+(a*a*a)
step 9: c=c/10
step 10: if sum equals to b then
print b count=count+1
step 11: b=b+1
step 12: Exit
Here is the Java Example for Armstrong Number with in Range:
import java.util.Scanner;
public class ArmstrongNumberWithinRange
{
public static void main(String args[])
{
Scanner s=new Scanner(System.in);
System.out.print("Enter the Range :");
int range=s.nextInt();
int a,b,c,sum,count=0;
b=1;
while(b<=range)
{
sum=0;
c=b;
while(c>0)
{
a=c%10;
sum=sum+(a*a*a);
c=c/10;
}
if(sum==b)
{
System.out.println(b+" is a Armstrong Number");
count=count+1;
}
b++;
}
System.out.println("Total Armstrong Number Present With in that Range is "+count);
}
}