Assignment 111; NestingLoops

Code

// Donovan Rich
// Period 6
// Nesting Loops
// 5/5/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 inner loops changes faster.
        // Swapping the n loop for the c loop causes the number to ascend faster than the letters.
		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 + " " );
			}
            // Changing the above to "println" causes each "a-b" to be on its own line.
			System.out.println();
            // This separates each line into a group of three "a-b"s.
		}

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

	}
}

    

Picture of the output