Assignment #111 Nested Loops
Code
///Name: Ian Grant
///Period:5
///Project Name: Nested Loops
///File Name:NestedLoops.java
///05/06/16
public class NestingLoops
{
/* #1 The Variable controlled by the inner loop changes faster.
#2 C changes faster this time
#3 It prints it verticaly instead of horizontaly
#4 It adds a space in between the groups
*/
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.println( a + "-" + b + " " );
}
System.out.println();
// * You will add a line of code here.
}
System.out.println("\n");
}
}
Output