Assignment #117

Code

/// Name: Jonathan Stine
/// Period: 5
/// Program Name: More Number Puzzles
/// File Name: MorePuzz.java
/// Date Finished: 5/1/2016
    
    import java.util.Scanner;
    
    public class MorePuzz {
        
        public static void main( String[] args ) {
            
            Scanner keyboard = new Scanner(System.in);
            int choice = 1;
            
            while ( choice != 3 ) {
                System.out.println();
                System.out.println( "MENU:" );
                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();
                System.out.println();
                
                if ( choice == 1 ) {
                    function1();
                } else if ( choice == 2 ) {
                    function2();
                }
            }
            
            
        }
        
        public static void function1() {
            for ( int i=1; i< 6; i++ ) {
                for ( int n=0; n< 10; n++ ) {
                    int c = n + i;
                    
                    if ( c > 10 ) {
                        int d = i * 10 + n;
                        if ( i < 5 || n < 7 ) {
                            System.out.println( d );
                        }
                    }
                    
                }
            }
        }
        
        public static void function2() {
            for ( int i=1; i< 10; i++ ) {
                for ( int n=0; n< 10; n++ ) {
                    int c = i + n;
                    int big = i * 10 + n;
                    int little = n * 10 + i;
                    int sub = big - little;
                    
                    if ( c == sub ) {
                        System.out.println( big );
                    }
                    
                }
            }
        }
    }

    
 
    

Code Output