You are on page 1of 5

QUEEN MARY, UNIVERSITY OF LONDON

BSC IN THE FACULTY OF ENGINEERING AND MATHEMATICAL SCIENCES


Student No:________________ UserId.__________________

MODULE: ECS401: PROCEDURAL PROGRAMMING AUTUMN 2007 MID TERM TEST


Time allowed where taken in exam conditions: 55 minutes. Answer ALL of the (multi-part) question There is one question on this test paper. Marks for each question part are indicated below each question part. The question is worth 25 marks. The mark for each question part (1a,1b,1c) is converted to a distinct A-F grade, each of which count towards your coursework grade. Answer the questions in accordance with the instructions given with each question
[Should your answer not fit in the space provided, you may continue on the reverse of the page provided that you indicate clearly the question number/part to which your answer relates]. For examiners use only Question 1a Question 1b Question 1c Mark Grade Mark Grade Mark Grade /6 /9 /10 6 A+ 9 A+ 9-10 A+ 5 A 8 A 7-8 A 4 B 7 B 6 B 3 C 5-6 C 5 C 2 D 4 D 4 D 1 E 2-3 E 2-3 E 0 F 0-1 F 0-1 F

IF USING THIS AS A MOCK PAPER NOTE THE GRADES MAY BE CALCULATED IN A DIFFERENT WAY IN FUTURE YEARS

Page 1 of 5

ECS401 Mid term Test Autumn 2007

Question 1 [25 marks] a) Explain what is meant by the i) declaration of a variable ii) initialisation of a variable . Illustrate your answers with appropriate examples. Answer:

[6 Marks] [Total Marks for Part 1a: 6 marks] Question 1 continues overleaf.

Page 2 of 5

ECS401 Mid term Test Autumn 2007

Question 1 continued. b) Give the final string value of z after each fragment of code in the question sub-parts below is executed. Justify your answers. i)
String z = A; String x = AA; x = x + x; Z = z + x;

Answer: Justification:

[2 Marks]

ii)
int x = 5; if(x>5) {z = B;} else if (x>3) {z = BB;} else if (x == 5) {z = BBB;} else {z = BBBB;}

Answer: Justification:

[2 Marks] Question 1 continues overleaf. Page 3 of 5 ECS401 Mid term Test Autumn 2007

Question 1 continued.

iii)
String z = C; for(int i = 1; i <= 3; i++) {z = z + CC;}

Answer: Justification:

[2 Marks]

iv)
String z = ; for(int i = 1; i <= 2; i++) { for(int j = 1; j <= 4; j++) {z = z + D;} }

Answer: Justification:

[3 Marks] [Total Marks for Part 1b: 9] Question 1 continues overleaf. Page 4 of 5 ECS401 Mid term Test Autumn 2007

Question 1 continued.

c) Write a Java program that allows football teams to be rated. It asks the user to type in the name of a player. The program then asks for a score out of 10 for how well that player played. Finally it prints a message about them containing their name and varying depending on the score: Flop! if the score was less than 5, Star! if the score was more than 8 and Solid otherwise. An example run of the program might go: Name? Sasha Score? 9 Sasha, you are a Star! Extend your program with a loop so that it does the above for each of the 11 players in the team in turn before ending. Your program should check for the range of the input (between 0 and 10), though you may assume that an integer is always input for the score. Answer:

[10 Marks]

[Total Marks for Question 1: 25]


END OF TEST Page 5 of 5 ECS401 Mid term Test Autumn 2007

You might also like