Assignemnt #119: Number Puzzles IV: A New Hope

Code

    /// Name: Cassie Rapp
    /// Period: 6
    /// Program Name: Number Puzzles IV: A New Hope
    /// File Name: PuzzIV.java
    /// Date Finished: 5/3/2016
    
    public class PuzzIV {
    
        public static void main( String[] args ) {
            
            for ( int a=1; a< 46; a++ ) {
                for ( int b=1; b < 46; b++ ) {
                    for ( int c=1; c< 46; c++ ) {
                        for ( int d=1; d< 46; d++ ) {
                            int sum = a + b + c + d;
                            int aMod = a + 2;
                            int bMod = b -2;
                            int cMod = c * 2;
                            int dMod = d / 2;
                            
                            if ( sum == 45 && aMod == bMod && bMod == cMod && cMod == dMod ) {
                                System.out.println( a + ", " + b + ", " + c + ", " + d );
                            }
                        }
                    }
                }
            }
        }
    }
    

Picture of the output

Assignment 119