Wednesday, September 18, 2013

Looking at Code: Alphabet Formatting

Hi Guys!  So obviously I'm out sick today.  Instead of starting on the Rock, Paper, Scissors code today, I want you to do two things:

1.) Finish up your Fewest Coins Possible code
2.) Explore and experiment with the code below.  What is it doing?  How does it work?  Can you change it?

This is an interesting use of formatting and a "for loop" as well as the ++ option to count up. Let's look at how it works:

public class Alphabet
{
public static void main(String [] args)
{
    char current = 'A';
    for(int row = 1; row <= 3; row++)
    {
        for(int column = 1; column <= 10; column++)
        {
            System.out.print(current + " ");
            current++;
        }
    System.out.println();
}
}
}

No comments:

Post a Comment