TITLE HET: DIPLOMA: INFORMATION TECHNOLOGY SUBJECT PROGRAMMING 1A SUBJECT CODE PRG120 TEST/EXAM EXAMINATION SEMESTER 1st DATE WRITTEN 13 June 2018 TOTAL MARKS 100 DURATION 1 HOUR 30 MINUTES PASS MARK 50% WEIGHTING 60% EXAMINER Mr MATHEBULA THABISO MODERATOR Mr JOHN ALLOZIEM REQUIREMENTS: Learner Requirements: Stationery Equipment Requirement: Computer installed with VB. Software This paper consists of: Marks 1. Section A: Short Questions 20 Marks 2. Section B: Medium Questions 20 Marks 3. Section C: Long Questions 60 Marks Unless otherwise stated, please answer ALL questions. PLEASE READ THE ASSESSMENT RULES AND REGULATIONS THAT FOLLOW Learners are warned that contravening any of the examination rules or disobeying the instructions of an invigilator could result in the examination being declared invalid. Disciplinary measures will be taken which may result in the students’ expulsion from Damelin. Diploma: In Information Technology Module: Programming 1A Module code: PRG120 Page 1 of 14 2018 ASSESSMENT RULES AND REGULATIONS Please ensure that you have read and fully understand the following assessment rules and regulations prior to commencing with your assessment: 1. To be permitted access to the examination, a learner must arrive with: 1.1 an Identity Document or other official proof of identity (for example, - a student card, passport or driver's licence card with photo); and 1.2 the required exam stationery. 2. No learner may enter the examination room more than 30 minutes after the examination sitting has commenced and no candidate may leave the room less than one hour after the examination sitting has commenced. 3. No extra time will be allowed should a student arrive late. 4. All learners must sign the Attendance Register for the examination on arrival. 5. It is the responsibility of learners to familiarise themselves with the examination rules prior to sitting for the examination. 6. All examinations are to be written on the date and time officially stipulated by the College. 7. It is the responsibility of learners to ensure that they are writing the correct paper and that the question paper is complete 8. Cell phones must be switched off prior to entering the exam venue. Cell phones and wallets may be placed under candidates' chairs rather than at the front of the room. 9. Learners may not handle cell phones or wallets during the exam. 10. No weapon of any description may be taken into the assessment room. 11. All personal belongings are to be placed at the front of the examination room. Personal belongings brought to the examination are at the owner's risk. 12. Smoking is not permitted and learners will not be allowed to leave the examination room in order to smoke 13. Once the examination has commenced, all conversation of any form between candidates must cease until after candidates have left the room, after the examination. 14. Only the official College examination book, as supplied by the College, may be used. 15. Learners must ensure that their student number is written on the answer book. 16. Learners are responsible for ensuring that they follow the instructions in the examination for submitting their answers. 17. Please read the instruction appearing on the examination paper carefully 18. The number of every question must be clearly indicated at the top of every answer. 19. No pages may be torn out of the answer book. All question papers and scrap paper must be handed to the invigilator after the examination. 20. Learners finishing earlier are to leave the examination room as quietly as possible on the instruction of the invigilator, and may not talk until outside the building where the examination is being written. 21. Only under exceptional circumstances will a learner be permitted to leave the examination room during the examination, and if the invigilator gives permission. An invigilator must accompany the learner. Only one learner at a time may be absent from the examination room. 22. Candidates may not act dishonestly in any respect. Diploma: In Information Technology Module: Programming 1A Module code: PRG120 Page 2 of 14 2018 SECTION A: SHORT QUESTIONS [20 MARKS] Answer all questions Question 1 [10] MULTIPLE CHOICE QUESTIONS Choose the correct answer: 1) Where decisions are made, computations are performed, and input/output requests are delegated. It also governs and manages all the processing which takes place inside the computer. a) Arithmetic logic b) CPU c) Input device d) Memory 2) What is the output of the following program: Public Class Form1 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Dim x As Integer = 1 Do While x <= 10 lsbDisplay.Items.Add(x) x -= 1 Loop End Sub End Class a) b) Diploma: In Information Technology Module: Programming 1A Module code: PRG120 Page 3 of 14 2018 c) d) No output, Infinite loop. 3) What is the output of the following program: Public Class Form1 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Dim x, y As Integer Dim s As String = " " For x = 1 To 15 For y = 1 To x s += " # " Next lsbDisplay.Items.Add(s) s="" Next End Sub End Class a) Diploma: In Information Technology Module: Programming 1A Module code: PRG120 Page 4 of 14 2018 b) c) d) Diploma: In Information Technology Module: Programming 1A Module code: PRG120 Page 5 of 14 2018 4) How many time will the word Hi be displayed on the list box when you run the following program? Public Class Form1 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Dim x As Integer = 2 Do lsbDisplay.Items.Add("Hi") x += x Loop Until (x <= 20) End Sub End Class a) 4 b) 1 c) 20 d) No output 5) How many time will the word Hi be displayed on the list box when you run the following program? Public Class Form1 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Dim x As Integer = 0 Do lsbDisplay.Items.Add("Hi") x += 1 Loop Until (x > 20) End Sub End Class a) 21 b) 20 c) 0 Diploma: In Information Technology Module: Programming 1A Module code: PRG120 Page 6 of 14 2018 d) 19 6) How many time will the word Hi be displayed on the list box when you run the following program? Public Class Form1 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Dim x As Integer = 1 While x < 20 lsbDisplay.Items.Add("Hi") x += 1 End While End Sub End Class a) 20 b) 19 c) 21 d) 0 7) How many time will the word Hi be displayed on the list box when you run the following program? Public Class Form1 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Dim x As Integer = 0 While x < 20 lsbDisplay.Items.Add("Hi") x += 1 End While End Sub End Class a) 21 b) 20 c) 19 d) 0 8) What will be displayed on the list box after running the following code: Public Class Form1 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Dim x As Integer = 15 If x < 20 Then If x < 10 Then lsbDisplay.Items.Add("Less than 10") Diploma: In Information Technology Module: Programming 1A Module code: PRG120 Page 7 of 14 2018 Else lsbDisplay.Items.Add("Large") End If End If End Sub End Class a) Nothing b) Less than 10 c) Large d) No output 9) What will be displayed on the list box after running the following code: Public Class Form1 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Dim x As Integer = 5 If x > 5 Then lsbDisplay.Items.Add("x is bigger than 5") End If lsbDisplay.Items.Add("That is all.") lsbDisplay.Items.Add("Goodbye") End Sub End Class a) X is bigger than 5 That is all. Goodbye b) That is all Goodbye c) Goodbye d) X is bigger than 5 10) What will be displayed on the list box after running the following code: Public Class Form1 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Dim x As Integer = 5 If x >= 5 Then lsbDisplay.Items.Add("x is bigger than 5") End If lsbDisplay.Items.Add("That is all.") lsbDisplay.Items.Add("Goodbye") End Sub Diploma: In Information Technology Module: Programming 1A Module code: PRG120 Page 8 of 14 2018 End Class a) X is bigger than 5 That is all. Goodbye b) That is all Goodbye c) Goodbye d) X is bigger than 5 Question 2 [10] TRUE AND FALSE QUESTIONS Write True or False, provide reason if you say False 2.1 Object-oriented programming is widely believed to be the significant breakthrough that can greatly enhance programmer productivity. 2.2 Early computers can perform multiple jobs or tasks at the same time. 2.3 A computer is an electronic device capable of performing computations and making logical decisions at speeds millions and even billions of times faster than those of human beings. 2.4 Distributed computing is when an organization’s computing is distributed over networks to the sites at which the work of the organization is performed, instead of the computing being performed only at a central computer installation. 2.5 A Computer is an electronic device which can receive information in a particular form and performing sequence of operations in accordance with a predetermined set of procedural instructions to produce a result. 2.6 A program is a set of instructions that can’t performs a specific task when executed by a computer 2.7 Multiprogramming involves the “simultaneous” operation of many jobs on a computer that splits its resources among those jobs. 2.8 Arithmetic Logic Unit performs some arithmetic and logic calculations. 2.9 Bits are smallest data item which can take either 0s or 1s. 2.10 Fields are group of related records. Diploma: In Information Technology Module: Programming 1A Module code: PRG120 Page 9 of 14 2018 SECTION B: MEDIUM QUESTIONS [20 MARKS] Answer all questions Question 3 [10] Consider the following GUI and the program below: Public Class Form1 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Dim x As Integer = 23 Dim y As Integer = 15 Dim temp As Integer = 0 temp = x x=y y = temp lsbDisplay.Items.Add("The value of x is " & x.ToString()) lsbDisplay.Items.Add("The value of y is " & y.ToString()) End Sub End Class 1) Explain in details what does the above program do? (6) 2) What is the output of the above program? (4) Question 4 [10] Consider the following GUI and incomplete code below Diploma: In Information Technology Module: Programming 1A Module code: PRG120 Page 10 of 14 2018 Public Class Form1 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load Dim marks As Integer = 70 'insert your code here End Sub End Class Complete the code above so that it will be able to display the following on the list box: If student’s grade is greater than or equal to 90 Display “A” ElseIf student’s grade is greater than or equal to 80 Display “B” Else If student’s grade is greater than or equal to 70 Display “C” ElseIf student’s grade is greater than or equal to 60 Display “D” Else Display “F” End IF Diploma: In Information Technology Module: Programming 1A Module code: PRG120 Page 11 of 14 2018 SECTION C: PRACTICAL [60 MARKS] Answer all questions Create a folder on the desktop with your name and surname and save your work in that folder. Question 5 [30] Start VB application and do the following: Create the following Graphical User Interface (GUI) and solve the problem below: Write a program that will verify whether the text boxes that have the label that has (*) are filled before submitting the form. And if the user click SUBMIT button with one of the text containing (*) not filled display an error massage box telling the user to fill in that space. And if all the text boxes are filled then display the following message box: Question 6 [30] Start vb and create the form below and rewrite the program below to make it operate in this form: Diploma: In Information Technology Module: Programming 1A Module code: PRG120 Page 12 of 14 2018 The program bellow has function calcAverage that compute and return the average of three marks. And the function gradeMarks compute and return the following messages based on the following criteria. Passed with distinction if the value of the mark is greater than or equal to 75 Passed if the value of the mark is greater than or equal to 50 Supplementary if the value of the mark is greater than or equal to 40 All marks below 40 it should return Failed. And the sub Display which display the marks and the computations of the functions. When the form load the program declare an integer array and initialize the memories of and array marks the call the sub display to display the results on the list box. Now to perfectly implement the program. Rewrite the program below in your vb and fill in the missing code from number 1 to 9 on the program. Follow the instructions on the program. Public Class Form1 'The beginning of the function calcAverage that will calculate(compute) and 'return the average of the marks Function calcAverage(ByVal mark1 As Integer, ByVal marsk2 As Integer, ByVal mark3 As Integer) As Integer '1. Implement the program that will compute and return average below. End Function 'Beginning of function gradeMarks Function gradeMarks(ByVal mark As Integer) As String '2. Implement the code that will return 'Passed with distinction if the mark is greater than or equal to 75 'Passed if the mark is greater than or equal to 50 'Supplementary with distinction if the mark is greater than or equal to 40 'Failed if the mark is below 40 End Function Sub Display(ByVal mark1 As Integer, ByVal mark2 As Integer, ByVal mark3 As Integer) Diploma: In Information Technology Module: Programming 1A Module code: PRG120 Page 13 of 14 2018 'displaying the first mark and calling the function gradeMarks to display the 'grade of the mark on the list box lsbDisplay.Items.Add("First mark: " + mark1.ToString() + " " + gradeMarks(mark1).ToString()) '3. display the second mark here and call the function gradeMarks to grade 'mark2 to display the mark on the list box '4. display the third mark here and call the function gradeMarks to grade 'mark3 to display the mark ‘on the list box '5. display the average of the mark by calling the function calcAverage End Sub Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load '6. declare an array marks of type integer which can load 3 values 'loading 25 in the first memory location of array marks marks(0) = 25 '7. code to load 80 in the second memory location of array marks '8. code to load the 65 in the third memory location of array marks '9. calling the sub Display End Sub End Class TOTAL MARKS: 100 Diploma: In Information Technology Module: Programming 1A Module code: PRG120 Page 14 of 14 2018