Assignment #119
Code
/// Name: Jonathan Stine
/// Period: 5
/// Program Name: Number Puzzles IV: A New Hope
/// File Name: NewHope.java
/// Date Finished: 4/28/2016
public class NewHope {
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 );
}
}
}
}
}
}
}
Code Output