0% found this document useful (0 votes)
2 views4 pages

IRE322 Exam Computation Methods 2024

The document is an examination paper for the course IRE 322: Computation Methods in Irrigation Engineering at Lilongwe University of Agriculture and Natural Resources. It includes instructions for answering the questions, which cover topics such as VBA programming, numerical integration, Gaussian elimination, and weather classification algorithms. The exam consists of four questions with various sub-questions requiring both theoretical explanations and practical coding tasks.

Uploaded by

comfortmbozole25
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views4 pages

IRE322 Exam Computation Methods 2024

The document is an examination paper for the course IRE 322: Computation Methods in Irrigation Engineering at Lilongwe University of Agriculture and Natural Resources. It includes instructions for answering the questions, which cover topics such as VBA programming, numerical integration, Gaussian elimination, and weather classification algorithms. The exam consists of four questions with various sub-questions requiring both theoretical explanations and practical coding tasks.

Uploaded by

comfortmbozole25
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Lilongwe University of Agriculture and Natural Resources

Bunda College Campus

Faculty of Agriculture

Agricultural Engineering Department

IRE 322: COMPUTATION METHODS IN IRRIGATION


ENGINEERING

2023/2024: End of Semester II Examination

Date: Tuesday, 21 May 2024 Time: 09:00 – 12:00 hours

Instructions
1. Answer ALL Questions.

2. There are four (4) questions and four (4) pages.

3. Use the provided answer book AND the IRE322 EXAM folder on the computer

desktop to write your answers.

4. You must write your answers LEGIBLY.

5. Start answering each question on a fresh page in the answer book.

Page 1 of 4
Question 1

(a) Write statements that perform each of the following tasks in VBA:
i. Modifies module settings to require all variables used in sub routines to be
explicitly declared. (2 marks)
ii. Declares a constant named ‘PI_VALUE’ and assign it the value of 3.142.
(4 marks)
iii. Declares a dynamic array named ‘arrayGPAs’ and resizes the array to the value
of the variable ‘noOfStudents’. (4 marks)

(b) Write a VBA function that will form part of a larger VBA program to evaluate and return
the correct answer for the following algebraic function.

− sin 𝑥 , 𝑓𝑜𝑟 𝑥 < 0


2𝑥, 𝑓𝑜𝑟 0 ≤ 𝑥 < 2
𝑓(𝑥) =
𝑥2, 𝑓𝑜𝑟 2 ≤ 𝑥 ≤ 4
{ 16, 𝑓𝑜𝑟 𝑥 > 4
(15 marks)

Question 2
(a) Give two reasons why you would use numerical integration method instead of analytical
methods. (5 marks)

(b) Use the Trapezoidal rule to approximate the area under the function 𝑓(𝑥) = 2𝑥 on the
interval [2,8]. Use 6 subintervals. (8 marks)

(c) Use the algorithm given in the pseudocode in Box 2 to write a VBA program to perform
the computation in Question 3(c). (12 marks)

Box 1 Pseudocode for Trapezoidal Rule algorithm


Given a function f(x):

(Get user inputs)


INPUT:
a, b = endpoints of interval,
n = number of intervals

(Do the integration)


SET h = (b - a)/n
SET SUM = 0
DO FOR i = 1 TO n - 1 STEP 1:
SET x = a + h*i
SET SUM = SUM + 2*f(x)
END DO (FOR i)
SET SUM = SUM + f(a) + f(b)
SET ANS = SUM * h/2

OUTPUT:
ANS

Page 2 of 4
Question 3
(a) State two setbacks of performing Gaussian elimination of linear equation systems by
hand. (2 marks)

(b) Explain the difference between Gaussian elimination and Gauss-Jordan elimination
methods. (4 marks)

(c) You are provided with VBA code for performing Gauss-Jordan elimination in the Excel
file GuassJordan4.xlsm located in the exam folder on the desktop. The code computes
the solution of a set of linear equations with three unknowns.

i. Use the VBA program to solve the following system of linear equations. (4 marks)
2𝑥2 + 𝑥4 = 0
2𝑥1 + 2𝑥2 + 3𝑥3 + 2𝑥4 = −2
4𝑥1 − 3𝑥2 + 𝑥4 = −7
6𝑥1 + 𝑥2 − 6𝑥3 − 5𝑥4 = 6

ii. Modify the VBA program so you can compute the solution for a set of linear
equations with nine unknowns. Note: save the new code in a file
GuassJordan9.xlsm. (8 marks)

(b) The truss in Figure 1 has six pin joints and nine members. Resolving the x and y
components of the forces in the truss results in the set of linear equations that follow.
Use the VBA program from Question 3 (c) ii to determine the forces in each member of
the truss. (7 marks)

𝐹1 cos 45° − 𝐹4 − 𝐹5 cos 30° = 0


𝐹1 sin 45° + 𝐹3 + 𝐹5 sin 30° = −1000
𝐹2 − 𝐹6 = 0
−𝐹3 = 0
𝐹4 − 𝐹9 sin 45° = −500
𝐹7 + 𝐹9 cos 45° = 0
𝐹5 cos 30° + 𝐹6 − 𝐹8 = 0
𝐹5 sin 30° + 𝐹7 = 0
𝐹8 + 𝐹9 cos 45° = 0

1000 N

F4
500 N
30˚
F1 45˚ 45˚
F5 F9
F3 F7

30˚
F2 F6 F8

Figure 1 Forces in a truss

Page 3 of 4
Question 4

(a) i. Define an algorithm. (2 marks)


ii. What is pseudocode? (2 marks)
iii. How does pseudocode differ from syntax in programming? (3 marks)

(b) Suppose you are asked to classify daily weather at a farm based on the observed
maximum temperature and rainfall. The classifications and the corresponding threshold
values are given in Table 1.
i. Write pseudocode to accept maximum temperature and rainfall as inputs, and
output the weather classification of the day. (9 marks)
ii. Use the pseudocode in 2(b) i. to write VBA code that will perform the daily
weather classification. (9 marks)

Table 1. Daily weather classification


Rainfall (mm) Mean temperature (°C) Classification
<= 5 <= 15 Cool dry
> 15 and <= 25 Warm dry
> 25 Hot dry
>5 <= 15 Cool wet
> 15 and <= 25 Warm wet
> 25 Hot wet

END OF EXAMINATION PAPER

Page 4 of 4

You might also like