Assignment #111 and Nested loops
Code
///Name:Ben borglin
///Period: 6
///Program Name: Nested loops
///File Name: nestedLoops.java
///Date finsihed: 1/28/26
public class nestedLoops
{
public static void main( String[] args )
{
// this is #1 - I'll call it "CN"
for ( char c='A'; c <= 'E'; c++ ) ///Variable 'c' changes faster
{
for ( int n=1; n <= 3; n++ )///Variable 'n' controlls the entire loop
{
System.out.println( c + " " + n );
}
}
///Switching the for loops changes the value of the 'char' or 'int' goes up.
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("LAWL");
}
///making it a println shifts the print down a line every loop
///Adding that line of code prints 3 lines of code in the for loop then shifts the next 3 lines down. and so on
System.out.println("\n");
}
}