Download as pdf or txt
Download as pdf or txt
You are on page 1of 9

DIPLOMA IN BUSINESS INFORMATION TECHNOLOGY

DIT 504: APPLICATION PROGRAMMING

OPEN BOOK EXAM

Name: Yahya Abdi

Reg No: 19/06582

Main Campus

DBIT Stage 4

LECTURER: GEOFFREY OCHIENG


QUESTION ONE (30 MARKS)

a) Write a function procedure that determines and returns the Blood Pressure Status of
the patient when Systolic and Diastolic parameters are fed in, using the criteria below.

i. Sketch/Draw the design of the interface.

ii. Using the IF Function, come up with the scenario below.

Blood Pressure Status Systolic(mmHg)


Normal 100-119
Elevated 120-129
Hypertension Stage 1 130-139
Hypertension Stage 2 140-180
Critical >180

Private Sub btnBloodpressureStatus_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles btnShowloodpressureStatus.Click
Dim Blood pressure Status As Integer
Dim systolic As Integer

BloodpressureStatus = txtBloodPressureStutus.Text
If = systolic(100-119) Then
txtBloodPressureStutus. .Text = "Normal"
ElseIf systolic(120-129) Then
txtBloodPressureStutus. .Text = "Elevated"

ElseIf systolic(130-139) Then


txtBloodPressureStutus. .Text = "Hypertention Stage"

ElseIf systolic(140-180) Then


txtBloodPressureStutus. .Text = "HPT stage2 "

ElseIf systolic(180) Then


txtBloodPressureStutus. .Text = "Critical"
End If
End Class

b) Write a function procedure that determines and returns BMI status given that

BMI value Status


0-18.50 Underweight
18.50-24.99 Normal
25.00-29.99 Overweight
>30 Obese
marks)
c) IF statements form a fundamental part of VB Programming when designing a
program logic that can be easily understood by the system user who is required to
follow specific rules when implementing an IF Statement system code.
Describe five rules that must be followed when writing “If Statement” programs in
Visual Basic.
1.A block If statement must always end with an End If statement.
2.The key word Then must appear on the same line as the word If.
3.The key words Else and End If must appear on lines by themselves.
4.The Else branch is optional (see example below). Only use an Else statement if
there is a False branch.
5.IF you have more than one condition, introduce the logic statement AND in your
code.

d) Give seven disadvantages of using traditional file-based database in an


organization. (7 Marks)

1) Data Redundancy: Since each application has its own data file, the same data may have
to be recorded and stored in many files. For example, personal file and payroll file, both
contain data on employee name, designation etc. The result is unnecessary duplicate or
redundant data items. This redundancy requires additional or higher storage space, costs
extra time and money, and requires additional efforts to keep all files up to-date.
2) Data Inconsistency: Data redundancy leads to data inconsistency especially when data is
to be updated. Data inconsistency occurs due to the same data items that appear in more
than one file do not get updated simultaneously in each and every file. For example, an
employee is promoted from Clerk to Superintendent and the same is immediately updated
in the payroll file may not necessarily be updated in provident fund file. This results in two
different designations of an employee at the same time. Over the period of time, such
discrepancies degrade the quality of information contain in the data file that affects the
accuracy of reports.
3) Lack of Data Integration: Since independent data file exists, users face difficulty in getting
information on any ad hoc query that requires accessing the data stored in many files. In
such a case complicated programs have to be developed to retrieve data from every file or
the users have to manually collect the required information.
4) Program Dependence: The reports produced by the file processing system are program
dependent, which means if any change in the format or structure of data and records in the
file is to be made, the programs have to modified correspondingly. Also, a new program will
have to be developed to produce a new report.
5) Data Dependence: The Applications/programs in file processing system are data
dependent i.e., the file organization, its physical location and retrieval from the storage
media are dictated by the requirements of the particular application. For example, in payroll
application, the file may be organized on employee records sorted on their last name, which
implies that accessing of any employee's record has to be through the last name only.
6) Limited Data Sharing: There is limited data sharing possibilities with the traditional
filesystem. Each application has its own private files and users have little choice to share the
data outside their own applications. Complex programs required to be written to obtain
data from several incompatible files.
7) Poor Data Control: There was no centralised control at the data element level, hence a
traditional file system is decentralised in nature. It could be possible that the data field may
have

QUESTION TWO (20 MARKS)

i). The following is a VB code extracted from a Visual Basic project. Use it to answer
the questions below.
[6 Marks]

priceonedecimal = (footballinteger * 44.0)


pricetwodecimal = (basketballinteger * 49.0)
pricethreedecimal = (volleyballinteger * 39.0)
subtotaldecimal = (priceonedecimal + pricetwodecimal + pricethreedecimal)
taxdecimal = (subtotaldecimal * 0.05)
totalsalesdecimal = (subtotaldecimal + taxdecimal)
priceoneTextBox.Text = priceonedecimal.ToString
pricetwoTextBox.Text = pricetwodecimal.ToString
pricethreeTextBox.Text = pricethreedecimal.ToString
subtotalTextBox.Text = subtotaldecimal.ToString

i. Identify two objects


-Refers to a thing –like a noun in English. Examples include forms,
buttons, text boxes etc.

pricetwoTextBox.Text
pricethreeTextBox.Text
ii. Identify two variables
footballinteger
basketballinteger
iii. Identify two operators
*
+

b) A windows form application is required that captures marks scored by a student in


two CATs via textboxes, then computes the difference between the two CATs and
outputs the result on a textbox “txtResult” once a button “Compute Total” is clicked.

Required:
i. Sketch a suitable design of the Form application using the controls mentioned
above.

ii. Write the code segment linked to the button “Compute Total” that will
display the total of what the student has scored on the two assignments.
[3 Marks]

Private Sub btnComputeTotal_Click(ByVal sender As System.Object, ByVal e


As System.EventArgs) Handles btnComputeTotal.Click
Dim catone As Integer
Dim cattwo As Integer
Dim difference As Integer
catone = txtCatOne.Text
cattwo = txtCatTwo.Text
difference = catone - cattwo
txtDifference.Text = difference.ToString

End Sub

c) Write a VB Program that captures the student names, marks for Assignment one and
Assignment two. If Assignment one is greater than 15 and Assignment two is greater
than 20, then the program should display the total of Assignment one and
Assignment two. Else if assignment one is less than 14 and assignment two is less
than 19 then the program should display the message “The student has a
Supplementary”. [4 Marks]
Dim assignment1decimal As Decimal
Dim assignment2decimal As Decimal
Dim totalscoredecimalAs Decimal
assignment1decimal = Assignment1TextBox.Text
assignment2decimal = Assignment2TextBox.Text
If assignment1decimal >= 15 And assignment2decimal >= 20 Then
totalscoredecimal= assignment1decimal + assignment2decimal
TotalscoreTextBox.Text= totalscoredecimal.ToString
ElseIfassignment1decimal <= 14 And assignment2decimal <= 19 Then
MessageBox.Show("The student has a supplemetary")
End If
End Sub

d) Differentiate between the following naming conventions and give examples in each
case.
i. Prefix naming of controls is a naming convention in which the first letter of
each word in a compound word is capitalized, except for the first word.
camelCase is useful in programming since element names cannot contain
spaces. E.g., NameTextBox, CourseTextBox etc.

ii. Suffix naming of controls is a naming convention that use an abbreviation for
the type as part of the variable name. E.g., txtName, txtCourse
(4 Marks)

You might also like