Assignemnt #117 and MorePuzzles
Code
/// name: Leila Ordukhani
/// period: 6
/// program name: One Hundred and Seven Program
/// file name: MorePuzzles.java
/// date finished: 5/3/16
import java.util.Scanner;
public class MorePuzzles
{
public static void main( String[] args ) throws Exception
{
Scanner k = new Scanner(System.in);
int choice;
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\n");
choice = k.nextInt();
System.out.println();
if (choice == 1)
fiftyTen();
else if (choice == 2)
reverseSum();
} while ( choice != 3 );
}
public static void fiftyTen()
{
for (int a = 1; a < 6; a++)
for (int b = 0; b < 10; b++)
{
int c = a + b;
if ( c > 10 )
{
int d = a*10 + b;
if ( a < 5 || b < 7 )
System.out.println( d );
}
}
}
public static void reverseSum()
{
for (int a = 1; a < 10; a++)
for (int b = 0; b < 10; b++)
{
int c = a*10 + b;
int d = b*10 + a;
int e = a + b;
if ( c - d == e)
System.out.println( c );
}
}
}
Picture of the output