Assignemnt #117 More Number Puzzles
Code
///Name: Morgan Kaplan
///Period: 5
///Project Name: More Number Puzzles
///File Name: NPT.java
import java.util.Scanner;
public class NPT
{
public static void main( String[] args )
{
Scanner momo = new Scanner( System.in );
int choice;
do
{
System.out.println( "1) Find two digit numbers <= 56 with sums of digits >10\n2) Find two digit number minus number reversed which equals sum of digits\n3) Quit" );
System.out.println("\n");
choice = momo.nextInt();
if (choice == 1 )
{
for ( int x = 10; x <= 50; x = x + 10 )
{
for ( int y = 1; y <= 9; y++ )
{
if ((x + y )<= 56 )
{
int z = x/10 + y;
if ( z > 10 )
System.out.println( x + y );
}
}
}
}
else if ( choice == 2 )
{
for ( int a = 1; a <= 9; a = a + 1 )
{
for ( int b = 1; b <= 9; b++ )
{
int c = a + b, d = a - b, e = b - a;
if ( b > a )
{
d = d - 1;
e = e + 10;
if ( (d + e) == c )
System.out.println( b + "" + a );
}
else
{
if ( (d + e) == c )
System.out.println( a + "" + b );
}
}
}
}
}while (choice != 3);
}
}
Picture of Output