Nested Loops #118 (Louis Armstrong))
Code
/// Name: Amir Salehi
/// Period: 7
/// Program Name: Number Puzzles III Armstrong Numbers
/// File Name:NPArmstrong.java
/// Date Finished: 5/2/2016
public class NPArmstrong
{
public static void main( String[] args )
{
System.out.println();
int x, y, z, a, b, c;
for ( x = 1; x <= 9; x++ )
{
for ( y = 0; y <= 9; y++ )
{
for ( z = 0; z <= 9; z++ )
{
a = x*x*x;
b = y*y*y;
c = z*z*z;
int armstrong = a+b+c;
int total = (x*100) + (y*10) + z;
if ( armstrong == total )
{
System.out.println( total );
}
}
}
}
System.out.println();
}
}
Picture(s) of the output