



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Main points of this exam paper are: Activate Timer, Console-Based, Visual Basic, Programming Project, Random Number, Integer Numbers, Calling Function
Typology: Exams
1 / 5
This page cannot be seen from the preview
Don't miss anything!




Semester 1 Repeat Examinations 2011
Module Code: COMP
School: Electrical and Electronic Engineering
Programme Title: Bachelor of Engineering in Electronic Engineering
Programme Code: ELES_L8_Y
External Examiner(s): Dr. A. Donnellan, Mr. I. Kennedy Internal Examiner(s): Donal O’Donovan
Instructions: All questions must be answered
Practical Section: Console and Windows: Using a PC with the Visual Basic.NET programming environment, complete the exercises indicated. [Examination percentage: 70 %]
Instructions: (a) Each program should be stored in a separate project folder. (Select the ‘Create new folder’ option when creating the project.) (b) Save all projects on the desktop. (c) The project name should be formatted as follows: o ‘name question number’, e.g., John_Smith_Q (d) The final projects should be copied to a machine designated by the invigilator at the end of the examination. o It is the student’s responsibility to verify the correct transfer of the project files to the invigilator’s machine. (e) The VB.NET code for each program should also be printed off and inserted into your answer book (see Theory Section). Your name and question number should be clearly marked on each print-out page.
Theory Section: A hand-written response is required for these questions. [Examination percentage: 30 %] Instructions: All questions should be answered in answer book provided.
NOTE: This is a closed-book examination. Although, you may use the help supplied by the Visual Basic programming environment, if you wish.
1. Write a console-based Visual Basic.NET programming project to perform the following:
i. Generate a random number between 100 and 1000 called FILE_SIZE. [3 %]
ii. Write a sub-procedure to: (a) Generate FILE_SIZE random integer numbers between 150 and
(b) Return the random numbers to the calling function, i.e. , main(), in an array of size FILE_SIZE and stored (in main()) in an integer array called dataArray. [3 %]
(c) The numbers should be written to a file, called ‘c:\myfolder\datafile.dat’. Each random number should be stored on a separate line. [7 %]
iii. Write a function, called RollingAverage, to calculate the average of five integer values passed by value as an array to the function. The ‘rolling’ average result should be returned as the result of the function call.
i.e. ,^0 1 2 3 5
array array array array array RollingAverage (^) [5 %]
iv. Define a structure, called RollingStruct, consisting of: [4 %]
o A rolling-average array, called RollingArray, which stores five integer elements (used in the calculation the rolling average in (iv)).
o A single-precision floating-point number used to store the corresponding rolling average value, called rollingAvg.
v. In main(), define an array of RollingStruct structures (see iv.), called structArray, of size FILE_SIZE – 4 and redim the RollingArray field of each structure to a size of 5 elements. [4 %]
vi. In main(), write code to populate the rolling-average array RollingArray in each RollingStruct structure of the array of structures structArray in (v) with integer data values from dataArray in (ii (b)).
iii. Display the currently-selected ListData item in the Display Label. [3 %]
iv. If the checkbox ‘Double speed’ is ticked, the timer speed should double. [4 %]
v. The scroll bar tab position should increase by one, resetting when the maximum position is reached. [4 %]
(c) Add a menu bar to your application with one menu called ‘File’ and insert an option to ‘Quit’ the program into the File submenu. [2 %]
[26 %]
(Continued Over)
In an examination booklet, answer the following:
(b) Explain the difference passing arguments to a function using the ‘byRef’ and ‘byVal’ options. [4 %]
(c) Demonstrate, using diagrams, how recursion may be used to generate Fibonacci series Fn Fn (^) 1 Fn 2 with seed values F 0 (^) 0 and F 1 (^) 1. Write code to implement the Fibonacci series. [10 %]
(d) Using diagrams to illustrate your answer, give a detailed explanation of the operation of the ‘Selection Sort’ sorting algorithm. [10 %]
[30 %]