Assignemnt #117 and More Number Puzzle
Code
///Name: Daniel Tiffany-Appleton
///Period: 7
///Program Name: More Number Puzzle
///File Name: MoreNumberPuzzle
///Date Finished: 3/23/16
import java.util.Scanner;
public class MoreNumberPuzzle
{
public static void main( String args[] )
{
Scanner keyboard = new Scanner(System.in);
int choice = 1;
do
{
System.out.println(" ");
System.out.println("1) Find two digit numbers <= 56 with sums of digits > 10");
System.out.println("2) Find two digit number minus number reversed which equals sum of digits");
System.out.println("3) Quit");
choice = keyboard.nextInt();
if( choice == 1 )
{
LessThan56();
}
else if( choice == 2 )
{
SelfMinusReverse();
}
else
{
return;
}
}while (choice != 3);
}
public static void LessThan56()
{
System.out.println(" ");
for( int x = 1; x <= 5; x++ )
{
for( int y = 1; y < 10; y++ )
{
int num = (x*10)+y;
int sum = x + y;
if( sum > 10 && num <= 56)
{
System.out.println("(" + x + "" + y + ")");
}
}
}
return;
}
public static void SelfMinusReverse()
{
for( int y = 1; y < 10; y++ )
{
for( int z = 0; z < 10; z++ )
{
int summ = y + z;
int number = (y*10)+z;
int inverseNum = (z*10)+y;
if( number - inverseNum == summ )
{
System.out.println(" ");
System.out.println("(" + y + "" + z + ")");
return;
}
}
}
}
}
Picture of the output