Assignement:Solving a Number Puzzle

Code

 /// Name: Sean Harrison
    /// Period: 7
    /// Program name: MoreNumPuzzle
    /// File Name: MoreNumPuzzle.java
    /// Date Finished: 5/3/2016
    
import java.util.Scanner;
import java.util.InputMismatchException;

public class MoreNumPuzzle
{
	public static void main( String[] args ) throws Exception
	{
		System.out.println();

		int choice = 0;

		do
		{
			choice = showMenu();

			System.out.println("\n");

			if (choice==1) optionOne();
			if (choice==2) optionTwo();

			System.out.println("\n");
		}
		while (choice!=3);

		System.out.println("Goodbye.");
	}

	public static int showMenu()
	{
		System.out.print("1) Find two digit numbers <= 56 with sums of digits > 10\n" +
				"2) Find two digit number minus number reversed which equals sum of digits\n" +
				"3) Quit\n" +
				"\n" +
				">");

		Scanner keyboard = new Scanner(System.in);

		int num = 0;

		try
		{
			num = keyboard.nextInt();
		}
		catch (InputMismatchException e)
		{
			System.out.println("Incorrect Input");
		}

		if (num < 1 || num > 3) System.out.println("Enter a number between 1 and 3.");
		return num;
	}

	public static void optionOne()
	{
		for ( int n = 1; n < 10; n++)
		{
			for ( int j = 0; j < 10; j++)
			{
				if ((n*10+j)<=56 && (n+j>10) )
				{
					System.out.print(n);
					System.out.print(j + "  ");
				}
			}
		}
	}

	public static void optionTwo()
	{
		for ( int n = 1; n < 10; n++)
		{
			for ( int j = 0; j < 10; j++)
			{
				if ((n*10+j)-(j*10+n)==(n+j) )
				{
					System.out.print(n);
					System.out.print(j+"  ");
				}
			}
		}
	}
}



            
       
 

Picture of the output

Assignment 117