Assignment 119; Hope
Code
// Donovan Rich
// Period 6
// Number Puzzles IV: A New Hope
// Hope.java
// 5/6/2016
public class Hope
{
public static void main( String[] args )
{
for ( int a=0; a <= 30; a++ )
{
for ( int b=0; b <= 30; b++ )
{
for ( int c=0; c<= 30; c++ )
{
for ( int d=0; d<=30; d++ )
{
if ( a+b+c+d == 45)
{
int check1=a+2, check2=b-2, check3=c*2, check4=d/2;
if ( check1 == check2 )
{
if ( check2 == check3 )
{
if (check3 == check4 )
{
System.out.println( a+ " " + b + " " + c + " " + d );
}
}
}
}
}
}
}
}
System.out.println("\n");
}
}
Picture of the output