Learning to Program—Flowcharting (Stage 2) – Case Statements

This entry is part 6 of 22 in the series Learning to Program

In my previous post, I described decisions and loops.  There is a special type of decision called a select- case statement (or case statement).  This decision is intended to replace the need for nested if- then statements.  First, I need to delve into the if- then statement a little more.

If- then- else statement:

An if- then- else statement is just an if statement that says “If the condition is true, then perform this action, else if the statement is false, perform this action.”

A nested if statement basically is an if –then else –if statement.  An example of this would be if average > 90 then grade is an “A” else if average > 80 then grade is a “B”……


Select- Case statement:

A select Case statement is a cleaner version of the nested if statement.  By cleaner I mean that you don’t have as much coding and as many decisions to make.  You have one decision (question) and list the possible outcomes. Each one has their actions.

The best example of a Select- case statement is a menu.  Of course, if there are only two or three options, then an if/else/if statement may be better.


Now that we’ve covered all of the decisions and loops that you’ll typically run into, we’ll move on to methods and classes.  Remember, this stage is just intended to see the flow, so don’t worry if you don’t understand what they are.

Have a great day:)

Series Navigation<< Learning to Program – Flowcharting (Stage 2). — Decisions and LoopsLearning to Program (Stage 2)—Flowcharting – Methods and Classes >>

Leave a comment

Your email address will not be published. Required fields are marked *