Knowee
Questions
Features
Study Tools

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.

Question

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.

...expand
🧐 Not the exact question you are looking for?Go ask a question

Solution

QUESTION 2 a) The IF statement can be implemented in Event Driven Programming in the following ways:

  1. Simple IF statement: This is used when we need to execute a certain block of code if the condition is true. Syntax: IF condition THEN 'code to be executed END IF

  2. IF-ELSE statement: This is used when we need to execute one 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

  3. Nested IF statement: This is used when we need to check for multiple conditions. Syntax: IF condition1 THEN 'code to be executed if condition1 is true IF condition2 THEN 'code to be executed if condition2 is true END IF END IF

b) The four main components in a Visual Basic Programming Environment are:

  1. The Code Editor: This is where you write your VB code.
  2. The Form Designer: This is where you design your application's user interface.
  3. The Solution Explorer: This is where you manage the files and resources in your project.
  4. The Properties Window: This is where you set the properties of the selected object.

QUESTION 3 a) Repetition structures in event driven programming: i. For Next: This loop is used when we know the exact number of times we want to loop through a block of code. Syntax: FOR counter = start TO end 'code to be executed NEXT counter

ii. Do loop until: This loop is used when we want to repeat a block of code as long as a condition is true. Syntax: DO UNTIL condition 'code to be executed LOOP

iii. Do while loop: This loop is used when we want to repeat a block of code as long as a condition is true. The difference with the 'Do loop until' is that this loop will execute the block of code at least once. Syntax: DO 'code to be executed LOOP WHILE condition

QUESTION 4 a) Two examples of event driven programming languages are Visual Basic and JavaScript.

b) To create a menu called Edit that has Cut, Copy, and Paste sub menus, you can use the MenuStrip control in VB.NET. First, you add a MenuStrip control to your form. Then, you add a top-level menu item called Edit. Finally, you add three sub menu items under Edit: Cut, Copy, and Paste.

c) Here is a simple program that reads in a number through a text box, and displays the cube of the number if it is greater than five; else it displays the square of the number.

Dim num As Integer = Integer.Parse(TextBox1.Text)
If num > 5 Then
   MessageBox.Show("The cube of the number is " & num * num * num)
Else
   MessageBox.Show("The square of the number is " & num * num)
End If

d) To set up a connection to a database using VB.NET, you can use the SqlConnection class in the System.Data.SqlClient namespace. Here are the steps:

  1. Import the System.Data.SqlClient namespace.
  2. Create a new instance of the SqlConnection class, passing the connection string to the constructor.
  3. Call the Open method of the SqlConnection object to open the connection.
  4. Use the SqlConnection object in your data operations.
  5. Call the Close method of the SqlConnection object to close the connection.

This problem has been solved

Similar Questions

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)

___________________executes different codes for more than two conditions0.5 Marksif...elsif..else statementif..else statementBoth A and Cif..elseif..else statement

Problem StatementA computer science teacher assigned the students a programming task that calculates and displays grades based on test marks. The teacher wants the program to take a student's test mark as input and determine their grade using the following criteria:If the mark is between 90 and 100 (inclusive), assign grade A.If the mark is between 80 and 89 (inclusive), assign grade B.If the mark is between 70 and 79 (inclusive), assign grade C.If the mark is between 60 and 69 (inclusive), assign grade D.If the mark is between 45 and 59 (inclusive), assign grade E.For marks below 45 assign grade F.If the mark is greater than 100 or a negative number, it displays "Invalid input". Help the students to accomplish the given task.Note: This question helps in clearing AMCAT exam.Input format :The input consists of a single integer, representing the student's mark.Output format :The output displays "Grade: " followed by the grade for the given mark based on the given criteria.If the mark is greater than 100 or a negative number, the output displays "Invalid input".Refer to the sample output for the formatting specifications.Code constraints :In the given scenario, the test cases fall under the following constraints:0 ≤ student's mark ≤ 100Sample test cases :Input 1 :100Output 1 :Grade: AInput 2 :85Output 2 :Grade: BInput 3 :79Output 3 :Grade: CInput 4 :63Output 4 :Grade: DInput 5 :56Output 5 :Grade: EInput 6 :0Output 6 :Grade: FInput 7 :-5Output 7 :Invalid inputInput 8 :126Output 8 :Invalid input

State and explain four features of java programming language (4 Marks)d) Write a Java program that determines a student’s grade. The program will read three types ofscores(quiz, mid-term, and final scores) and determine the grade based on the following rules: -if theaverage score >=90% =>grade=A -if the average score >= 70% and <90% => grade=B -if theaverage score>=50% and <70% =>grade=C -if the average score<50% =>grade=F(7 Marks)

State SIX important rules that a VB programmer is supposed to follow whenever he/she iswriting IF statement logic codes.

1/3

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.