Assignment 2 - Control Flow Statements

Due Before class on Oct 17th.

Control flow statements together with expressions and declarations (declaring new variables, etc.) are the building blocks from which all Java programs are built. I want to stress that the only way to get your mind around control flow, or anything else is programming is to write some programs using them just like I was doing in class. Experiment with them. Make mistakes and learn how to find the answers you need to fix them. Just reading a book won't do.

The assignment is to prepare for a quiz next Thursday on control flow statements in Java by writing some short programs that demonstrate the use of each one and emailing them to me. You could make one big program that shows them all off or several short programs that each use one or more types of control flow statements. For example switch statements usually have some break statements in them. You'll need to right a function in at least one of your programs to use the return statement.

The Java Tutorial has a nice section covering control flow statements here: Control Flow Statements. These are the ones I would like you to be familiar with at this point:

You don't need to study about the exception handling statements, continue, or labels at this stage.

You'll be able to find examples of all these statements all over the web and in books about java.

The format of the quiz will be questions about short pieces of code provided as well as a few questions asking you to write some similar code snippets. If you haven't been writing some on your own you'll probably have trouble with these.

Finally, here is a link to the switch statement code I was playing with in class. Your programs don't have to be any more complicated than this.