Assignemnt #111 NestingLoops.java
Code
/// Name: Boris Kazantsev
/// Period: 6
/// Program Name: NestingLoops
/// File Name: NestingLoops.java
/// Date Finished: 5/17/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 );
}
}
// #1. The second variable 'n' changes faster.
// #1. It is controlled by the outer loop (c).
// #2. Loop n changes fater after changing the order.
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();
// * You will add a line of code here.
}
System.out.println("\n");
// #3. Only a pair of nubmers displays on each line.
// #4. Three pairs of nubmers dispaly on each line.
}
}
Picture of the output