Assignment 111 , Nesting Loops
Code
///Name: Stella Koliavas
///Period: 5
///Program Name: Nesting Loops
///File Name: NestingLoops.java
///Date Finshed: 5/9/16
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 );
}
}// variable controlled by n
//when order changes the variables go through E rather than to 3
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.println( a + "-" + b + " " );
}
System.out.println("test");
}//when println added the second set of code has a line each
//the new line of code is added after each set of 3 is reached
System.out.println("\n");
}
}
Picture of the output