a) With the use of appropriate syntax explain THREE ways in which the IF statement can beimplemented in Event Driven Programming. (6 marks)b) Describe FOUR main components in a Visual Basic Programming Environment. (8 marks)c) Draw a flowchart for a program that calculates the average of three grades and prints theaverage. The word GOOD should be printed only if the average is more than 80. (6 marks)
Question
a) With the use of appropriate syntax explain THREE ways in which the IF statement can beimplemented in Event Driven Programming. (6 marks)b) Describe FOUR main components in a Visual Basic Programming Environment. (8 marks)c) Draw a flowchart for a program that calculates the average of three grades and prints theaverage. The word GOOD should be printed only if the average is more than 80. (6 marks)
Solution
a) In Event Driven Programming, the IF statement can be implemented in three ways:
- Simple IF Statement: This is the most basic form of the IF statement. It checks if a condition is true and if it is, it executes a block of code. Syntax:
If condition Then
'code to be executed if condition is true
End If
- IF-ELSE Statement: This form of the IF statement checks a condition and executes a block of code if the condition is true, and another block of code if the condition is false. Syntax:
If condition Then
'code to be executed if condition is true
Else
'code to be executed if condition is false
End If
- IF-ELSEIF-ELSE Statement: This form of the IF statement is used when multiple conditions need to be checked. If the first condition is false, it checks the next condition and so on. If none of the conditions are true, it executes the code in the ELSE block. Syntax:
If condition1 Then
'code to be executed if condition1 is true
ElseIf condition2 Then
'code to be executed if condition2 is true
Else
'code to be executed if none of the conditions are true
End If
b) The four main components in a Visual Basic Programming Environment are:
-
Form Designer: This is where you design the user interface for your application. You can add controls such as buttons, text boxes, labels, etc.
-
Solution Explorer: This is where you manage the files and resources in your project. You can add, remove, and rename files and resources here.
-
Properties Window: This is where you can change the properties of the selected control in the Form Designer. For example, you can change the text of a button, the color of a form, etc.
-
Code Editor: This is where you write the code for your application. The code you write here determines how your application behaves.
c) Here is a simple flowchart for the program:
Start
|
V
Input grade1, grade2, grade3
|
V
Calculate average = (grade1 + grade2 + grade3) / 3
|
V
If average > 80 Then
Print average
Print "GOOD"
Else
Print average
End If
|
V
End
Similar Questions
greater than zero respectively. Display an appropriate message in case of violation.(8 marks)QUESTION 2 (20MARKS)a) With the use of appropriate syntax explain THREE ways in which the IF statement can beimplemented in Event Driven Programming. (6 marks)b) Describe FOUR main components in a Visual Basic Programming Environment. (8 marks)c) Draw a flowchart for a program that calculates the average of three grades and prints theaverage. The word GOOD should be printed only if the average is more than 80. (6 marks)QUESTION 3 (20MARKS)a) Using basic codes describe the following repetition structures in event driven programming.i. For Next (2 marks)ii. Do loop until (2 marks)iii. Do while loop (2 marks)b) Write a program that can be used to calculate the surface area of the next world cup ball.(8 marks)c) Design a code that can ensure that the user can Cut, Copy, and Paste items from one text boxto another text box by right clicking the mouse button. (6 marks)QUESTION 4 (20MARKS)a) Outline TWO examples of event driven programming languages. (2 marks)b) Explain how you can create a menu called Edit that has Cut, Copy, and Paste sub menus.(6 marks)c) Design a program that reads in a number through a text box. If the number is greater than five,it displays the cube of the number; else it displays the square of the number. (6 marks)d) Demonstrate the steps involved in setting up a connection to a database or other types of datasource using VB.NET.
State SIX important rules that a VB programmer is supposed to follow whenever he/she iswriting IF statement logic codes.
Describe three different ways of declaring variables in VB (6 Marks
a) Explain the purpose of the following objects as used in VB.NET.i. Button (2 marks)ii. Text Box (2 marks)iii. Label (2 marks)iv. Radio Button (2 marks)b) Write a code that can display the following message box: (8 marks)c) Discuss THREE types of errors one is likely to encounter in event driven programming.(6 marks)d) Draw a GUI and write a program to show case how items can be added, deleted, and countedin a list box control. (8 marks)e) Describe TWO main ways that you can a VB.NET project. (4 marks)f) Design a basic VB.NET program that displays; your official names, registration number, yourlecturer’s name, and lecturer’s email address. (6 marks)SECTION A (QUESTION ONE IS COMPULSORY AND CHOSE ANY OTHER TWOQUESTIONS)QUESTION 1 (COMPULSORY 20MARKS)a) With examples distinguish between the following terms as used in Event driven programming;i. Entity (2 marks)ii. File (2 marks)iii. Record (2 marks)iv. Table (2 marks)b) A program is required to determine the gross pay for each of the several employees of acertain company. The company pays “straight-time” for the first 40 hours worked by eachemployee and pays “one-and a half time” for all hours worked in excess of 40 hours. You aregiven a list of employees in the company, the number of hours each employee worked and thehourly rate of each employee. You are to design a program in which you should input thisinformation for each employee, and then compute and display the employee’s gross pay. use textboxes for both inputs and outputs.Required:i. Design the graphical user interface for this program (4 marks)ii. Write a program code to compute the gross pay. Your program should validate the inputsin such a way that the names of the employees must be input, the number of hoursworked and pay rate must be numeric, greater than zero but less than or equal to 60 andgreater than zero respectively. Display an appropriate message in case of violation.(8 marks)QUESTION 2 (20MARKS)a) With the use of appropriate syntax explain THREE ways in which the IF statement can beimplemented in Event Driven Programming. (6 marks)b) Describe FOUR main components in a Visual Basic Programming Environment. (8 marks)c) Draw a flowchart for a program that calculates the average of three grades and prints theaverage. The word GOOD should be printed only if the average is more than 80. (6 marks)QUESTION 3 (20MARKS)a) Using basic codes describe the following repetition structures in event driven programming.i. For Next (2 marks)ii. Do loop until (2 marks)iii. Do while loop (2 marks)b) Write a program that can be used to calculate the surface area of the next world cup ball.(8 marks)c) Design a code that can ensure that the user can Cut, Copy, and Paste items from one text boxto another text box by right clicking the mouse button. (6 marks)QUESTION 4 (20MARKS)a) Outline TWO examples of event driven programming languages. (2 marks)b) Explain how you can create a menu called Edit that has Cut, Copy, and Paste sub menus.(6 marks)c) Design a program that reads in a number through a text box. If the number is greater than five,it displays the cube of the number; else it displays the square of the number. (6 marks)d) Demonstrate the steps involved in setting up a connection to a database or other types of datasource using VB.NET. (6 marks)
List any 3 objects and 3 events used in VB and explain their functions.
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.