AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
Conditional Logic: Exercises
1. Visual Basic Programming [Lesson 1 To Lesson 3]
1 of 2
Conditional Logic: Exercises
Author: Kasun Ranga Wijeweera
Email: krw19870829@gmail.com
Date: 2020 May 27
1)
a) Start a new Visual Basic Windows Forms Application project.
b) Add a text box to the form and name it as txtNum.
c) Add a button to the form and name it as btnCheck.
d) Change the Text property of the button to “Check”.
e) Program the button according to the steps given below.
f) The user is expected to enter an integer in the text box.
g) The text “Even” should be displayed in a message box if the integer entered in the text
box is even. Otherwise the text “Odd” should be displayed in a message box.
2)
a) Start a new Visual Basic Windows Forms Application project.
b) Add a text box to the form and name it as txtNumber.
c) Add a button to the form and name it as btnInRange.
d) Change the Text property of the button to “Is in Range?”.
e) Program the button according to the steps given below.
f) The user is expected to enter a number in the text box.
g) The text “Yes” should be displayed in a message box if the number is greater than or
equal to 5 AND less than 12. Otherwise the text “No” should be displayed in a message
box.
3)
a) Start a new Visual Basic Windows Forms Application project.
b) Add a text box to the form and name it as txtNumber.
c) Add a button to the form and name it as btnInRange.
d) Change the Text property of the button to “Is in Range?”.
e) Program the button according to the steps given below.
f) The user is expected to enter a number in the text box.
g) The text “Yes” should be displayed in a message box if the number is less than 3 OR
greater than 17. Otherwise the text “No” should be displayed in a message box.
2. Visual Basic Programming [Lesson 1 To Lesson 3]
2 of 2
4)
a) Start a new Visual Basic Windows Forms Application project.
b) Add four text boxes with names txtX1, txtY1, txtX2, txtY2 and label them as “x1”, “y1”,
“x2”, “y2” respectively.
c) The four text boxes represent the coordinates of two points (x1, y1) and (x2, y2).
d) Add a button to the form and name it as btnCoincide.
e) Change the Text property of the button to “Is Coincide?”.
f) Program the button according to the steps given below.
g) The text “Yes” should be displayed in a message box if the two points coincide.
Otherwise the text “No” should be displayed in a message box.
5)
a) Start a new Visual Basic Windows Forms Application project.
b) Add four text boxes with names txtX1, txtY1, txtX2, txtY2 and label them as “x1”, “y1”,
“x2”, “y2” respectively.
c) The four text boxes represent the coordinates of two points (x1, y1) and (x2, y2).
d) Add a button to the form and name it as btnDistinct.
e) Change the Text property of the button to “Is Distinct?”.
f) Program the button according to the steps given below.
a) The text “Yes” should be displayed in a message box if the two points coincide.
Otherwise the text “No” should be displayed in a message box.
6)
a) Start a new Visual Basic Windows Forms Application project.
b) Add a text box to the form with name txtMarks and label it as “Marks”.
c) Add a button to the form and name it as btnGrade.
d) Program the button according to the steps given below.
e) The user is expected to enter a number from 0 to 100 in the text box.
f) The number in the text box is marks.
g) The grade is calculated based on the marks according to the table given below.
marks grade
80 ≤ marks < 100 A
60 ≤ marks < 80 B
40 ≤ marks < 60 C
20 ≤ marks < 40 D
0 ≤ marks < 20 E
h) The grade should be displayed in a message box.