Assignment # 117 and More Puzzles
Code
/// Name: Tommy Oyuntseren
/// Period: 7
/// Program Name: MorePuzzles
/// File Name: MorePuzzles.java
/// Date: 5/6/16
import java.util.Scanner;
public class MorePuzzles
{
public static void main(String[] args)
{
Scanner keyboard = new Scanner(System.in);
int x=0;
do
{
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");
System.out.println("");
System.out.print(">");
int choice = keyboard.nextInt();
System.out.println("");
if (choice == 1 )
choiceOne();
else if (choice == 2)
choiceTwo();
else if (choice == 3)
{
x=1;
}
} while (x != 1);
}
public static void choiceOne()
{
for (int a=0; a< 6; a++)
for (int b=0; b< 10; b++)
{
int f = a+b;
int g = (10*a) + b;
if ((f > 10) && (g <= 56))
{
System.out.println(a + "" + b);
System.out.println();
}
}
}
public static void choiceTwo()
{
for (int c=1; c< 10; c++)
for ( int d=0; d< 10; d++ )
{
if ((((c*10)+d) - ((d*10)+c)) == (c + d))
{
int e = (10*c) + d;
System.out.println(e);
System.out.println();
}
}
}
}
Picture of the output