Assignment #111
Code
///Name: Cody Swain
///Period: 6
///Project Name: NestedLoops
///File Name: NestedLoops.java
///Date: 5/2/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 inner loops variable changes 3 times per 1 time the outer loop changes. Therefore the inner loop is changing much faster.
2. For each number, all the letters from a -> e will be printed with a number after.
3. This makes it so after each "1-1" individual thing it will go to the next line.
4. This makes it so after each complete set beginning with the same number, it will go to the next line.
*/
Picture of the output