Program #119

Code

   
    /// Name: Afaf Nabeeha
    /// Period: 7
    /// Program Name: Number Puzzles IV: A New Hope
    /// File Name: Hope.java
    /// Date Finished: 3/8/2016 public class Hope

        public class Hope
        {
            public static void main( String[] args ) 
            {
                for ( int a = 0; a <=45; a++ )
                {
                    for( int b = 0; b<=45; b++ )
                    {
                        for( int c = 0; c <=45; c++ )
                        {
                            for ( int d = 0; d<=45; d++ )
                            {
                                int e = a + b + c + d;
                                if ( e == 45 )
                                {
                                    int f = a + 2;
                                    int g = b - 2;
                                    int h = c * 2;
                                    int i = d / 2;
                                    if ( f == g && h == i )
                                    {
                                        if ( f == h && g == i )
                                        {
                                            System.out.println(a+" + "+b+" + "+c+" + "+d+" = "+e );
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }

             
    

Picture of the output

Assignment 119