Assignemnt #111 and Nesting Loops
Code
/// Name: Kyle Ivy
/// Period: 5
/// Program Name: NestingLoops
/// File Name: NestingLoops.java
/// Date Finished: 4/20/2016
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 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
*/
prog111.PNG