IRE322 Exam Computation Methods 2024
IRE322 Exam Computation Methods 2024
Faculty of Agriculture
Instructions
1. Answer ALL Questions.
3. Use the provided answer book AND the IRE322 EXAM folder on the computer
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.
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)
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)
1000 N
F4
500 N
30˚
F1 45˚ 45˚
F5 F9
F3 F7
30˚
F2 F6 F8
Page 3 of 4
Question 4
(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)
Page 4 of 4