Assignment #119 and Number Puzzles IV: A New Hope

Code

    /// Name: Lauren Baird
    /// Period: 7
    /// Program Name: Number Puzzles IV: A New Hope
    /// File Name: NumberPuzzles4.java
    /// Date Finished: 1/29/2016
    
    public class NumberPuzzles4
    {
        public static void main( String[] args )
        {
            System.out.println();
            int w, x, y, z;
            
            for ( w = 0; w <= 45; w++ )
            {
                for ( x = 0; x <= 45; x++ )
                {
                    for ( y = 0; y <= 45; y++ )
                    {
                        for ( z = 0; z <= 45; z++ )
                        {
                            int total = w + x + y + z;
                            int a = 2 + w;
                            int b = x - 2;
                            int c = y * 2;
                            int d = z / 2;
                            
                            if ( a == b && b == c && c == d && total == 45 )
                            {
                                System.out.println( w + ", " + x + ", " + y + ", " + z );
                            }
                        }
                    }
                }
            }
            System.out.println();
        }
    }                          
    

Picture of the output

Assignment #119