Assignment #118 Number Puzzles III: Armstrong Numbers
Code
/// Name: John Huh
/// Period: 6
/// Program Name: Number Puzzles III: Armstrong Numbers
/// File Name: Puzzles3.java
/// Date Finished: 4/26/2016
import java.util.Scanner;
public class Puzzles3
{
public static void main( String[] args ) throws Exception
{
Scanner keyboard = new Scanner(System.in);
System.out.println();
for ( int x=1; x<=9; x++ )
{
for ( int y=0; y<=9; y++ )
{
for ( int z=0; z<=9; z++ )
{
int a = x*100 + y*10 + z;
int b = (x*x*x) + (y*y*y) + (z*z*z);
if ( a == b )
{
System.out.println( x + "" + y + "" + z );
}
}
}
}
System.out.println();
}
}
Picture of the output