Assignemnt #117 and More Number Puzzles
Code
/// Name: Kyle Ivy
/// Period: 5
/// Program Name: Puzzle2.java
/// File Name: Puzzle2
/// Date Finished: 4/20/2016
import java.util.Scanner;
public class Puzzle2
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
int option;
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 digits. ");
System.out.println( "3) Quit");
System.out.println();
System.out.print(">");
option = keyboard.nextInt();
if (option == 1)
func1();
else if (option == 2)
func2();
}while (option != 3);
}
public static void func1(){
System.out.println();
for (int a=0; a<=5; a++){
for (int b=0; b<10; b++){
if ( (a+b)>10 && (((a*10)+b) <= 56 ) ){
System.out.print(a);
System.out.print(b);
System.out.print(" ");
}
}
}
System.out.println();
System.out.println();
}
public static void func2(){
System.out.println();
for (int a=1; a<10; a++){
for (int b=0; b<10; b++){
int c = (10*a)+b;
int d = (10*b)+a;
int e = a+b;
if ( (c - d) == e )
System.out.print(c);
}
}
System.out.println();
System.out.println();
}
}
prog117.PNG