Public note by Holland M. Wesley · @hmw55

D278: Conditional Statements and Decision Making Explained

One of the most important abilities of any computer program is the ability to make decisions.

Should a user be allowed to log in?

Should a student pass a class?

Should an online order qualify for free shipping?

Programs answer questions like these using conditional statements.

Conditional statements allow software to evaluate information and choose different actions based on the results.

In WGU D278: Scripting and Programming Foundations, understanding conditionals is essential because they appear throughout programming logic, pseudocode, algorithms, and the Objective Assessment.

This guide explains conditional statements, comparison operators, Boolean expressions, common mistakes, and how to solve conditional logic questions on the OA.


What Is a Conditional Statement?

A conditional statement allows a program to make decisions.

A condition is evaluated.

If the condition is true, one action occurs.

If the condition if false, another action may occur.

Example:

if grade >= 70
     pass

If the grade if 70 or higher:

pass

If not:

do not pass

The program chooses a path based on the condition.


Why Are Conditional Statements Important?

Without conditionals, software could never react to information.

Consider a few examples

ATM

if pin in correct 
     allow access

Online Store

if cart total > 50 
     free shipping

School System

if score >= 70
     pass

Almost every program uses conditional logic.


Understanding True and False

Conditional statements depend on Boolean values.


A boolean can only be True or False.

Every condition ultimately evaluates to one of these values.

Example:

grade >= 70

If:

grade = 85

the condition becomes:

85 >= 70

Result:

True

Comparison Operators

Comparison operators compare two values.

Operator

Meaning

==

Equal to

!=

Not equal to

>

Greater than

<

Less than

>=

Greater than or equal to

<=

Less than or equal to

These operators frequently appear on the Objective Assessment.


The IF Statement

The most common conditional statement is IF.


Example:

if age >= 18
     allow voting

The condition is checked first.

If true: allow voting

If false: Nothing happens


IF-ELSE Statements


Often a program needs two possible outcomes.

Example:

if score >= 70
     pass
else
     fail

Possible results:

Student Scores 85

85 >= 70 which means pass

Student Scores 60

60 >= 70 which means fail


IF-ELSE-IF Chains

Programs sometimes need more than two outcomes.

Example

if score >= 90
     A
else if score >= 80
     B
else if score >= 70
     C
else
     F

This allows multiple decisions to be evaluated.


Nested Conditionals

A conditional statement can contain another conditional.

Example:

if accountExists
     if passwordCorrect
          login

The second condition is only checked if the first condition is true.

Nested conditionals are common in real-world software.


Tracing Conditional Statements

Consider:

score = 75 

if score >= 70
     pass
else 
     fail

Step 1:

75 >= 70

Step 2:

True

Step 3:

pass

The final outcome is:

pass


Common Mistakes Students Make

Mistake #1: Not Evaluating the Condition

Students often jump directly to an answer.

Always evaluate the condition first.

Mistake #2 Confusing Operators

Sometimes students confuse > with >=.

Example:

score >= 70

A score of exactly 70 passes.

Example:

score > 70

A score of exactly 70 does not pass.


This difference appears frequently on exams.

Mistake #3: Ignoring ELSE

Students sometime focus only on the IF condition.

Remember:

If the IF condition if false, the ELSE branch executes.

Mistake #4: Reading Too Quickly

A question may look similar to another question while producing a completely different result.


Read every option carefully.


Real-World Examples

Login System

if passwordCorrect
     login
else
     deny access

Online Shopping

if total >= 50
     free shipping
else
     shipping fee

Gaming

if health <= 0
     game over

Objective Assessment Tips

When solving conditional questions:

  1. Read the condition carefully.
  2. Substitute actual values.
  3. Evaluate the comparison
  4. Determine whether the result is True or False.
  5. Follow the correct branch.

Do not skip steps.

Many OA mistakes happen because students assume instead of evaluating.

Coming soon: note forking. In the future, learners will be able to build on public notes while preserving attribution.