Nested Loops #119 (Nothing Starwars related copyright)
Code
/// Name: Amir Salehi
/// Period: 7
/// Program Name: Number Puzzles IV A New Hope
/// File Name:NPANewHope.java
/// Date Finished: 5/3/2016
public class NPANewHope
{
public static void main( String[] args )
{
System.out.println();
int w, x, y, z;
for ( w = 0; w <= 45; w++ )
{
for ( x = 0; x <= 45; x++ )
{
for ( y = 0; y <= 45; y++ )
{
for ( z = 0; z <= 45; z++ )
{
int total = w + x + y + z;
int a = 2 + w;
int b = x - 2;
int c = y * 2;
int d = z / 2;
if ( a == b && b == c && c == d && total == 45 )
{
System.out.println( w + ", " + x + ", " + y + ", " + z );
}
}
}
}
}
System.out.println();
}
}
Picture(s) of the output