Assignment #118

Code

      /* 
jack newsom
period 5
program Armstrong
filename Armstrong.java
date completed 11/16/2015
*/


public class Armstrong 
{
    public static void main( String[] args )
    {
        for ( int hundreds = 100; hundreds <= 900; hundreds = hundreds + 100 )
        {
            for ( int tens = 0; tens <= 90; tens = tens + 10 )
            {
                for ( int ones = 0; ones <= 9; ones = ones + 1 )
                {
                    int firstDigit = hundreds/100;
                    
                    int secondDigit = tens/10;
                    
                    int thirdDigit = ones;
                    
                    int actual = hundreds+tens+ones;
                    
                    firstDigit = firstDigit*firstDigit*firstDigit;
                    
                    secondDigit = secondDigit*secondDigit*secondDigit;
                    
                    thirdDigit = thirdDigit*thirdDigit*thirdDigit;
                    
                    int cubeSum = firstDigit + secondDigit + thirdDigit;
                    
                    if ( cubeSum == actual )
                    {
                        System.out.print( actual + " "  );
                    }
                    
                    
                    
                    
                    
                }
            }
        }
        
        System.out.println();
    }
}
    

Picture of the output