Assignment #111

Code

    
    Name: Santino Mattia
    Period: 6
    Project Name: NestedLoops
    File Name: NestingLoops.java
    Date: 6/7/16
    
    
    
    public class NestingLoops
    {
        public static void main( String[] args )
        {
            for ( int n=1; n <= 3; n++ )
            {
                for ( char c='A'; c <= 'E'; c++ )
                {
                    System.out.println( c + " " + n );
                }
            }
    
            System.out.println("\n");
    
            // this is #2 - I'll call it "AB"
            for ( int a=1; a <= 3; a++ )
            {
                for ( int b=1; b <= 3; b++ )
                {
                    System.out.print( a + "-" + b + " " );
                }
                System.out.println();
            }
    
            System.out.println("\n");
    
        }
    }
    
    
    /*
    1. The variable controlled by the inner loop, n, is the quicker-changing variable. For every one time the outer-controlled variable changes, the inner-controlled variable changes 3 times.
    2. The output changes by printing out a repetition of A-E 3 times, printing numbers 1-3 in a row - each number occurring 5 times before, and printing 3 rows of code - each number, 1-3, a dash, and then 1-3 again.
    3. The output changes by printing out a repetition of A-E 3 times, printing numbers 1-3 in a row - each number occurring 5 times, and lastly printing 3 vertical columns of 3 lines of code - each starting number has its own column, and then it is followed by a dash, then the numbers 1-3 in ascending order.
    4. Adding this statement after the close brace of the inner loop, but still inside the outer loop, changes the output by making there be rows of 3x3 #-# code at the bottom of the page, instead of keeping those #-# codes in one horizontal line.
    */

                
    



    

Picture of the output

Assignment 111