Assignement:Calculating ArmStrong Numbers with Nested Loops
Code
/// Name: Sean Harrison
/// Period: 7
/// Program name: ArmStrongNumber
/// File Name: ArmStrongNumber.java
/// Date Finished: 5/5/2016
public class ArmstrongNumber
{
public static void main( String[] args ) throws Exception
{
System.out.println();
for ( int n = 1; n < 10; n++)
{
for ( int j = 0; j < 10; j++)
{
for ( int k = 0; k < 10; k++)
{
if ( (n*100+j*10+k)== Math.pow(n,3)+ Math.pow(j,3) + Math.pow(k,3))
{
System.out.print(n);
System.out.print(j);
System.out.print(k+" ");
}
}
}
}
System.out.println();
}
}
Picture of the output