Download Economical - Advanced Programming - Exam and more Exams Computer Programming in PDF only on Docsity!
Ollscoil na hÉireann, Gaillimh GX_____
National University of Ireland, Galway
Autumn Examinations 2008/
Exam Code(s) 3BF
Exam(s) Third Year BSc in Business Information Systems
Module Code(s) MS
Module(s) Advanced Programming
Paper No. 1
Repeat Paper
External Examiner(s) Professor H. van der Heijden
Internal Examiner(s) Professor J. F. Collins
Dr. T. Acton
Instructions: Answer any THREE QUESTIONS.
All questions carry equal marks.
Duration 2 hrs
No. of Answer books
Requirements :
Handout
MCQ
Statistical Tables
Graph Paper
Log Graph Paper
Other Material
No. of Pages 5 excluding this page
Department(s) Accountancy and Finance
OLLSCOIL NA hÉIREANN
NATIONAL UNIVERSITY OF IRELAND, GALWAY
AUTUMN EXAMINATIONS 2008/
THIRD YEAR BSc. IN BUSINESS INFORMATION SYSTEMS
EXAMINATION
(MS315) ADVANCED PROGRAMMING
Professor H. van der Heijden
Professor J. F. Collins
Dr. T. Acton
Time Allowed: TWO hours
Answer any THREE QUESTIONS. All questions carry equal marks.
Q1.
Car drivers can be concerned with the fuel economy of their cars. On one long
journey a particular driver has recorded the number of kilometres driven
together with the number of litres of fuel consumed. Write a javascript to take
as input the kilometres driven and litres of fuel used: the program should
calculate and output XHTML text that displays the fuel economy in litres per
100km as well as in kilometres per gallon. Where the latter is less than 45 km
per gallon, the program should inform the user that their car is uneconomical:
where this figure exceeds 70 km per gallon, the program should inform the
user that their car is economical. Assume that there are 4.54 litres per gallon.
The partially completed script is provided below (you do not need to rewrite
the provided code in your answer).
Q1: Fuel Economy Script
Click Refresh (or Reload) to run this script again.
(33.3 marks)
// Section 4 to explain
for ( $counter = 0; $row = mysql_fetch_row( $result ); $counter++ ){ // build table print( "" );
// Section 5 to explain
foreach ( $row as $key => $value ) print( "$value" ); print( "" ); }
// Section 6 to explain
mysql_close( $database ); ?>
(33.3 marks)
Q3.
Describe the purposes and usage of each of the following technologies. In
each case give a short example (in code) of a business-related implementation.
(a) Javascript Objects
(b) Cascading Style Sheets
(33.3 marks)
Q4.
(a) The following script has 6 distinct syntactical or logical errors on 6
separate lines. The purpose of the script is to prompt the user to enter 5
numbers and to display the largest and second largest numbers only.
Indicate the line numbers where the errors are located, and give the correct
line of code in each case.
01 02 04 05 07 6 Errors Here 08 09
19 if ( number > largest ) then { 20 nextLargest = largest; 21 number = largest; 22 } 23 else if ( number > nextLargest ) 24 nextLargest = number; 25 26 counter++; 27 } 28 alert( "Two largest numbers: " + 29 largest + " and " + nextLargest ); 30 // --> 31 32 33 34 (12 marks)
(b) Write JavaScript statements to accomplish each of the following tasks:
(i) Display the third element of array m
(ii) Print the integers from 1 to 20 using a for loop and the counter
variable i. Assume that i has been declared but not initialised.
Print only 5 integers per line.
(iii) Total the elements of array p , which contains 20 numeric
elements.
(9.33 marks)
(c) Write Unix commands to accomplish each of the following tasks:
(i) List the contents of the current directory in long format,
visually indicating whether content types are folders,
executables, or text files.
(ii) Pipe the contents of a file named ‘species.txt’ to the appropriate
word count command to determine the file’s word count.
(iii) Rename a file called ‘important’ to ‘not_so_important’.
(iv) Change file permissions on a file named ‘stuff.txt’ so that only
the owner of the file can execute and write to it.
(v) Create a folder called ‘backup’ as a copy of a non-empty folder
called ‘documents’.
(vi) Search for the text string ‘expenditure’ in the file ‘taxes.txt’
(12 marks)
Q 5.
The following is a line-numbered Windows CGI Perl script. Give a thorough
explanation of what exactly is occurring in non-blank and non-commented
lines of code.
01 #!C:\Perl\bin\perl 02 # authors.pl 03 # CGI program that generates a list of authors 04