Download presentation
Presentation is loading. Please wait.
Published byBrandon Tyrone Lee Modified over 8 years ago
2
MULTIPLE ALTERNATIVES IF… THEN… ELSEIF SELECT CASE
3
MULTIPLE ALTERNATIVES IF... THEN… ELSEIF
4
Basic Structure of If.. Then… ElseIf If Then Statement 1 ElseIf Then Statement 2 ElseIf Then Statement 3 Else Statement 4 End If
5
Example: ** Make a program that will ask the user to enter his/her year level and display the corresponding loyalty award. YEAR LEVELLOYALTY AWARD 1BRONZE 2SILVER 3GOLD 4PLATINUM Other number / levelNo Available Award
6
SAMPLE Source Code If YrLevel = 1 Then Label1.Text = “BRONZE” ElseIf YrLevel = 2 Then Label1.Text = “SILVER” ElseIf YrLevel = 3 Then Label1.Text = “GOLD” ElseIf YrLevel = 4 Then Label1.Text = “PLATINUM” Else Label1.Text = “No Available Award” End If
7
MULTIPLE ALTERNATIVES SELECT CASE STATEMENT
8
Basic Structure of Select Case Select Case Case test condition 1 statement/s Case test condition 2 statement/s Case test condition n statement/s Case Else statement/s End Select
9
Where: Select Case – used at the beginning of the Select Case statement - may be a variable, numeric or string expression Case - an expression that evaluates to true or false
10
Case Else – keyword used to execute the statements if all case test conditions evaluate to false - block of codes to be executed if the test condition is true End Select – keyword used to end the select case statement
11
SAMPLE PROBLEM An instructor uses a grading scheme to assign letter grades in an examination. Given the numeric grade, display the corresponding letter grade of the student using the chart below: Numeric GradeLetter Grade 90 – 100 A 80 – 89 B 70 – 79 C 60 – 69 D 0 – 59 E
12
Visual Interface
13
Source Code Numeric Grade Letter Grade 90 – 100 A 80 – 89 B 70 – 79 C 60 – 69 D 0 – 59 E
14
SAMPLE OUTPUT
16
QUIZ 1 (Size 2 LW) B. Program Coding Make a program that will accept the age of a child and will determine the corresponding insurance premium if a parent would get an educational insurance for the child.
17
CHILD’S AGEEDUCATIONAL PREMIUM Below 110,000 1 – 415,000 5 – 820,000 9 – 1225,000 13 – 1630,000
19
LADDERIZED IF, ELSEIF STATEMENTS If Age < 1 Then Premium.Text = 10000 ElseIf Age >= 1 Then Premium.Text = 15000 ElseIf Age >= 5 Then Premium.Text = 20000
20
ElseIf Age >= 9 Then Premium.Text = 25000 ElseIf (Age >= 13) And (Age <= 16) Premium.Text = 30000 Else Premium.Text = 0 End If
21
SELECT CASE Select Case Age Case 0 Premium.Text = 10000 Case 1 To 4 Premium.Text = 15000 Case 5 To 8 Premium.Text = 20000
22
Case 9 To 12 Premium.Text = 25000 Case 13 To 16 Premium.Text = 30000 End Select
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.