Assignment #119 and Number Puzzles IV: A New Hope

Code

                        /// Name: Graham Pollock
                        /// Period: 5
                        /// Program Name: NP4
                        /// File Name: NP4.java
                        /// Date Finished: 05/07/2016/

       public class NP4
    {
        public static void main(String[] args)
        {
            for (int a = 0; a < 46; a++)
            {
                for (int b = 0; b < 46; b++)
                {
                    for (int c = 0; c < 46; c++)
                    {
                        for (int d = 0; d < 46; d++)
                        {
                            int sum = a + b + c + d;
                            int eA = a + 2;
                            int eB = b - 2;
                            int eC = c * 2;
                            int eD = d / 2;
                            
                            if (eA == eB && eB == eC && eC == eD && sum == 45)
                            {
                                System.out.println(a + ", " + b + ", " + c + ", " + d);
                            }
                        }
                    }
                }
            }
        }
    }
    

Picture of the output

Assignment