


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!



(NFQ Level 6)
Answer any (^) four questions Maximum available marks is 100.
Examiners: Mr. P Cogan Ms. S. Rea Mr. J. Berry Dr. R. Dubhghaill
Q1. (a) Write a note discussing how each of the following relates to writing BASIC programs; (i) Algorithms (ii) Stepwise refinement. (iii) Debugging. (iv) Modular programming. [8 marks]
(b) Explain each line of the following program, draw the program’s output and describe what happens if the numbers 5 and 0 are entered. [10 marks] DIM L AS SINGLE DIM C, P, A AS INTEGER CLS PRINT DO INPUT "Enter the L value ", L C = 1 P = 0 'starting P is 0 DO WHILE C < L P = P + 1 C = 2 ^ P LOOP PRINT "P is "; PRINT P; " for L= "; L PRINT "C ="; C INPUT "Another calculation "; A LOOP WHILE A = 1 PRINT "Good Bye" END
(c) Write a simple BASIC program that reads in the names and marks of two students. The program should then report on which student had the highest mark and whether any of the students failed (their mark was less than 40). [7 marks] (25 Marks in total) continued overleaf ….
Q2. (a) Using examples explain the following Excel spreadsheet functions;
(i) vlookup (ii) average (iii) goalseek [7 marks] (b) Write a BASIC program that reads in an exam mark and grades it as follows; 0 to 30 = F 30 to 40 = E 40 to 50 = Pass 50 to 60 = Merit 2 60 to 70 = Merit 1 70 or above = Distinction [6 marks]
(c) Write a BASIC program that simulates a fortune-teller. It should read in a question from the user and then generate a random number between 1 and 5. Based on this random number it should display one of the following messages.
Random Number Message 1 Yes, definitely 2 Ask again, later 3 No way! 4 It is certain. 5 Yes [12 marks] (25 Marks in total)
Q3. (a) Distinguish between count controlled and event controlled loops giving appropriate examples of each. [4 marks]
(b) Give the syntax of the following two BASIC statements: (i) FOR … NEXT (ii) DO … LOOP [4 marks]
(c) Distinguish between post-test loops and pre-test loops. [2 marks]
(d) Write a program, using NESTED FOR LOOPS , which produces the following output:
**** [5 marks] continued overleaf ….
Option 1 should calculate and display capacitance(C) using the formula
d
where ε is the permittivity of the dielectric, A is the area of the plates and d is the distance between them. The program should read in ε, A and d and not proceed with the calculation until a positive value is entered for d.
Option 2 should calculate and display the time constant (τ) of an RC circuit using τ=RC where R is the resistance and C is the capacitance. Under no circumstances should either R or C be negative, the values entered must be checked to prevent this.
Option 3 should display a table of the time constants for a circuit with a resistance that varies between two limits using the formula in option 2. The user should enter C and the starting and finishing resistance. The user should also be asked to enter the increment size that R will change by in the table. For example if C =10 and the increment size is 2, the program might generate a table that looks like this; R(ohms) Time constant(s) 1 10 3 30 5 50
Option 4 should cause the program to quit. (^) [20 marks]
(25 Marks in total)
ooooOOOOoooo