Assignemnt #113 Number Puzzle
Code
/// Name: JJ Deng
/// Period: 6
/// Program Name: More Number Puzzle
/// File Name: MoreNP.java
/// Date Finished: 5/3/2016
import java.util.Scanner;
public class MoreNP{
public static void main(String[] args){
Scanner keyboard = new Scanner(System.in);
int choice = 0;
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");
System.out.println();
System.out.print("> ");
choice = keyboard.nextInt();
if ( choice == 1 ) one();
if ( choice == 2 ) two();
}
while (choice != 3);
System.out.println("ummmmmmcya");
}
public static void one()
{
for ( int i = 1; i < 10; i++)
{
for ( int j = 0; j < 10; j++)
{
if ((i*10+j)<=56 && (i+j>10) )
{
System.out.print(i);
System.out.print(j + " ");
}
}
}
System.out.println();
}
public static void two()
{
for ( int i = 1; i < 10; i++)
{
for ( int j = 0; j < 10; j++)
{
if ((i*10+j)-(j*10+i)==(i+j) )
{
System.out.print(i);
System.out.print(j+" ");
}
}
}
System.out.println();
}
}
Picture of the output