Assignment 117, More Number Puzzles
Code
///Name: Stella Koliavas
///Period: 5
///Program Name: NumberPuzzle2
///File Name: NumberPuzzle2.java
///Date Finshed: 5/25/16
import java.util.Scanner;
public class NumberPuzzle2
{
public static void main( String[] args )
{
Scanner siri = new Scanner(System.in);
int choice = 1;
do{
System.out.println( " ");
System.out.println( "1) Find two digit numbers <= 56 and whose sum is greater than
10 ");
System.out.println( "2) Find two digit number minus the reversal of that number that
equals the sum of the digits");
System.out.println( "3) Quit");
System.out.println( " ");
System.out.print( "> ");
choice = siri.nextInt();
System.out.println( " ");
if (choice == 1)
for ( int x= 10; x <= 50; x = x + 10 )
{
for ( int y=1; y < 10 ; y++ )
{
int c = y + (x/10);
int d = (x + y);
if (c > 10 && d <= 56)
System.out.println(d);
}
}
if (choice == 2)
{
for ( int x=1; x < 10; x++ )
{
for ( int y=1; y < 10 ; y++ )
{
int c = y + x;
int d = (x*10) +y;
int e = (y * 10) +x;
if ( (d-e) == c )
System.out.println( d +" - " + e );
}
}
}
}while (choice != 3);
}
}
Picture of the output