



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




Section A (20 Marks) Attempt all 10 questions Mark your answers on the MCQ sheet provided
Section B (80 Marks) Answer Any TWO Questions Question 2 Review the following application and explain the purpose of the application and how it works. Explain, line by line, the purpose of each class and procedure. Where possible sketch the relevant forms and outputs. Use the line numbers for reference purposes. 1 Public Class ShippingForm 2 3 Dim RateDecimal(,) As Decimal = _ 4 {{1D, 1.5D, 1.65D, 1.85D}, _ 5 {1.58D, 2D, 2.4D, 3.05D}, _ 6 {1.71D, 2.52D, 3.1D, 4D}, _ 7 {2.04D, 3.12D, 4D, 5.01D}, _ 8 {2.52D, 3.75D, 5.1D, 7.25D}} 9 Dim WeightInteger() As Integer = {1, 3, 5, 10} 10 Dim ZoneString() As String = {"A", "B", "C", "D"} 11 12 Private Sub LookupButton_Click(ByVal sender As System.Object, _ 13 ByVal e As System.EventArgs) Handles LookupButton.Click 14 15 Dim WeightIndexInteger As Integer 16 Dim ZoneIndexInteger As Integer 17 Dim IndexInteger As Integer = 0 18 Dim WeightInputInteger As Integer 19 Dim WeightFoundBoolean As Boolean = False 20 Dim ZoneFoundBoolean As Boolean = False 21 22 Try 23 24 WeightInputInteger = Integer.Parse(weightTextBox.Text) 25 Do Until WeightFoundBoolean Or IndexInteger > 3 26 If WeightInputInteger <= WeightInteger(IndexInteger) Then 27 WeightIndexInteger = IndexInteger 28 WeightFoundBoolean = True 29 Else 30 IndexInteger += 1 31 End If 32 Loop 33 If Not WeightFoundBoolean Then 34 35 WeightIndexInteger = 4 36 WeightFoundBoolean = True 37 End If 38 39 IndexInteger = 0 40 Do Until ZoneFoundBoolean Or IndexInteger > 3 41 If ZoneTextBox.Text.ToUpper = ZoneString(IndexInteger) Then 42 ZoneIndexInteger = IndexInteger 43 ZoneFoundBoolean = True 44 Else 45 IndexInteger += 1 46 End If 47 Loop 48 49
50 If ZoneFoundBoolean Then 51 ChargesLabel.Text = _ 52 RateDecimal(WeightIndexInteger, ZoneIndexInteger).ToString("N") 53 Else 54 MessageBox.Show("Invalid zone.", "Information Missing or Invalid", _ 55 MessageBoxButtons.OK, MessageBoxIcon.Exclamation) 56 End If 57 Catch 58 MessageBox.Show("Invalid weight.", "Information Missing or Invalid", _ 59 MessageBoxButtons.OK, MessageBoxIcon.Exclamation) 60 End Try 61 End Sub 62 End Class 63 (40 Marks)