Pseudo code – Selection Structure, Two Paths

So far when we talked about the Section Structure we indicated we wanted to do something when the stated condition was True and do nothing at all when the condition was False.

When we want to do something when a condition is True and something different when the condition is False we use the keyword word Else

Get Age
 
If Age > 65 Then
      Compute DiscountAmount = PurchaseAmount * .1
Else
      Let DiscountAmount = 0
EndIf

Subtact DiscountAmount from PurchaseAmount      ‘unconditional statement
Compute Tax = PurchaseAmount * .075       ‘unconditional statement
 
Report PurchaseAmount and Tax


 Another Example

Get HoursWorked and PayRate
 
If HoursWorked > 40 then
      Compute GrossPay = (HoursWorked – 40) * (PayRate * 1.5) + (40 * PayRate)
Else
      Compute GrossPay = HoursWorked * PayRate
EndIF
 
Compute StateTax = GrossPay * .03     
 ‘unconditional statement
 
Report GrossPay and StateTax