- Learning to Program—The stages of programming
- Learning to Program – Some Terms You Should Understand
- Learning to Program – IPO Charts (Stage 1)
- Learn to Program- Flowcharting (Stage 2)
- Learning to Program – Flowcharting (Stage 2). — Decisions and Loops
- Learning to Program—Flowcharting (Stage 2) – Case Statements
- Learning to Program (Stage 2)—Flowcharting – Methods and Classes
- Learning to Program – Structure and Spaghetti Code
- Learning to Program – Pseudocode (Stage 3) an overview
- Learning to Program – Stage 3 Pseudocode commands and reserved words
- Learning to Program—Stage 3 Pseudocode examples Part 1
- Learning to Program – Stage 3 Psuedocode (Arrays)
- Learning to Program – Stage 3: Pseudocode—Methods
- Learning To Program—Stage 3.5 (UML Diagrams)
- Learning to Program – (Stage 4) Coding
- Learning To Program—Stage 5 Testing
- Learning to Program—Stage 6 (Documentation)
- Learning to Program – Stage 7 (Maintenance)
- Learning to Program—Random Thoughts with a Theme
- Learning to Program- Two Main Types of Errors
- Learning to Program – Integrated Development Environments (IDE’s)
- 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:)