Assignemnt #111 Nesting Loops
Code
///Name: Morgan Kaplan
///Period: 5
///Project Name: Nesting Loops
///File Name: NL.java
public class NL
{
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 );
}
}
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.print( "I'm cooest cat in the litter" );
}
System.out.println("\n");
}
}
///inner loop is faster, variable controlled by inner loop
///2. letters change more but numbers remain the same
///3. a-b numbers are on a new line.
///4. repeats fot every time "a" increases
Picture of Output