Assignment #111 and Nesting Loops
Code
/// Name: Graham Pollock
/// Period: 5
/// Program Name: NestingLoops
/// File Name: NestingLoops.java
/// Date Finished: 04/19/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( n + " " + c );
}
}
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");
}
}
///the variable n changes much faster because it changes 3 times every time c changes
///the output changes by counting numebr then charater, not character then number
///the output changes by displaying th enumber pairs vetically rather than horizontally
///the output changes by making it a new line everytime b counts to 3 and everytime a changes
Picture of the output