Assignemnt #111 Nesting Loops

Code

     ///Name: Prooz Fereydouni
    ///Period: 7
    ///Project Name: Nesting Loops
    ///File Name: NestingLoops.java
    ///Date: 5/8/2016
    
public class NestingLoops
{
    public static void main( String[] args )
    {
        // this is #1 - I'll call it "CN"
        for ( int n=1; n <= 3; n++ )
        {
            for ( char c='A'; c <= 'E'; c++ )
            {
                System.out.println( c + " " + n );
            }
        }
        // the numbers(or the n variable) which is displayed by the inner loop is changes quicker.
        //wehn we change the inner and outer loops the order by which the for loops are run are changed and we see that the letters change first and they change faster than the numbers.

        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 + " " );
                // the numbers start each line instead of being on one line all together.
            }
            System.out.println();
            // after the inside loop ends each time, the new set of numbers are printed on the next line.
        }

        System.out.println("\n");

    }
}

    

Picture of the output

assignment111