Assignment #119 Number Puzzles IV: A New Hope
Code
/// Name: John Huh
/// Period: 6
/// Program Name: Number Puzzles IV: A New Hope
/// File Name: Puzzles4.java
/// Date Finished: 4/27/2016
import java.util.Scanner;
public class Puzzles4
{
public static void main( String[] args ) throws Exception
{
Scanner keyboard = new Scanner(System.in);
System.out.println();
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 a2 = a+2;
int b2 = b-2;
int c2 = c*2;
int d2 = d/2;
int e = a+b+c+d;
if ( a2 == b2 && b2 == c2 && c2 == d2 && e == 45 )
{
System.out.println( a + " " + b + " " + c + " " + d );
}
}
}
}
}
System.out.println();
}
}
Picture of the output