Programming Assignment #117
Code
import java.util.Scanner;
public class Puzzle{
public static void main(String[] args){
Scanner k = new Scanner(System.in);
while(true){
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 = k.nextInt();
if(choice == 1){
for(int i = 1; i <= 9; i++){
for(int u = 0; u <= 9; u++){
String sNum = i + "" + u;
int num = Integer.parseInt(sNum);
if(num <= 56 && i + u > 10){
System.out.println(num);
}
}
}
}
else if(choice == 2){
for(int i = 1; i <= 9; i++){
for(int u = 0; u <= 9; u++){
String sNum = i + "" + u;
String rsNum = u + "" + i;
int num = Integer.parseInt(sNum);
int rNum = Integer.parseInt(rsNum);
if(num - rNum == i + u){
System.out.println(num);
}
}
}
}
else{
break;
}
}
}
}
Outputs