Computer Science For First Examination In 2021 9618 · 20

20.1 Programming paradigms

145 questions in this subtopic. Open a question to solve it and check the official answer.

Reset
2022 October-November · Paper 42 · Q2(f)

Programming paradigms · 7 marks · official answer ready

(f) The user will enter a letter to identify the direction the chosen character from part 2(e) should move. • If ‘A’ is input, the character moves left (x coordinate minus 1). • I…

2022 October-November · Paper 42 · Q2(g)(i)

Programming paradigms · 2 marks · official answer ready

(i) When a change to a character’s position has been made, the program needs to output the character’s name and the new x and y coordinates of the character, in the format: Qui ha…

2022 October-November · Paper 42 · Q2(g)(ii)

Programming paradigms · 1 mark · official answer ready

(ii) Test your program by inputting the following four items of data in the order given: THOMAS qui X A Take a screenshot of the output. Copy and paste the screenshot into part 2(…

2022 October-November · Paper 43 · Q2(a)(i)

Programming paradigms · 5 marks · official answer ready

(i) Write program code to declare the class Card, its attributes and constructor. Do not write program code for the get methods. Use your programming language appropriate construc…

2022 October-November · Paper 43 · Q2(a)(ii)

Programming paradigms · 3 marks · official answer ready

(ii) Write program code for the class methods GetNumber() and GetColour(). Save your program. Copy and paste the program code into part 2(a)(ii) in the evidence document. [3] 5

2022 October-November · Paper 43 · Q2(a)(iii)

Programming paradigms · 2 marks · official answer ready

(iii) The program is tested with the following cards: Number Colour 1 red 2 red 3 red 4 red 5 red 1 blue 2 blue 3 blue 4 blue 5 blue 1 yellow 2 yellow 3 yellow 4 yellow 5 yellow W…

2022 October-November · Paper 43 · Q2(b)(i)

Programming paradigms · 6 marks · official answer ready

(i) Write program code to declare the class Hand, its attributes and constructor. Do not write the get methods. Use your programming language appropriate constructor. All attribut…

2022 October-November · Paper 43 · Q2(b)(ii)

Programming paradigms · 2 marks · official answer ready

(ii) The get method GetCard() takes an index as a parameter and returns the card stored at that index in the array. Write program code for the method GetCard(). Save your program.…

2022 October-November · Paper 43 · Q2(b)(iii)

Programming paradigms · 2 marks · official answer ready

(iii) Two players are declared with 5 cards each. Player 1 has the cards: 1 red, 2 red, 3 red, 4 red, 1 yellow. Player 2 has the cards: 2 yellow, 3 yellow, 4 yellow, 5 yellow, 1 b…

2022 October-November · Paper 43 · Q2(c)(i)

Programming paradigms · 6 marks · official answer ready

(i) Write program code for the function CalculateValue(). Assume that there are only 5 cards in the player’s hand in this function. Save your program. Copy and paste the program c…

2022 October-November · Paper 43 · Q2(c)(ii)

Programming paradigms · 4 marks · official answer ready

(ii) Amend the main program by writing program code to use the function CalculateValue() for each of the two players. The player with the highest score wins. Output an appropriate…

2022 October-November · Paper 43 · Q2(c)(iii)

Programming paradigms · 1 mark · official answer ready

(iii) Test your program. Take a screenshot to show the output. Copy and paste the screenshot into part 2(c)(iii) in the evidence document. [1] 8

2021 October-November · Paper 31 · Q2

Programming paradigms · 4 marks · official answer ready

2 Draw one line from each programming paradigm to its most appropriate description. Programming paradigm Description Programs using the instruction set of a processor Declarative …

2021 October-November · Paper 41 · Q2(a)

Programming paradigms · 5 marks · official answer ready

(a) The constructor takes the picture description, frame colour, height, and width as parameters and sets these to the private attributes. Write the program code to declare the cl…

2021 October-November · Paper 41 · Q2(b)

Programming paradigms · 3 marks · official answer ready

(b) The four get methods return the associated attribute, for example, GetDescription() returns the description of the picture. Write the four get methods. Save your program. Copy…

2021 October-November · Paper 41 · Q2(c)

Programming paradigms · 2 marks · official answer ready

(c) The method SetDescription() takes a new description as a parameter, and writes this value to the appropriate attribute. Write the method SetDescription(). Save your program. C…

2021 October-November · Paper 41 · Q2(d)

Programming paradigms · 1 mark · official answer ready

(d) Write program code to declare an array of type Picture with 100 elements. Save your program. Copy and paste the program code into part 2(d) in the evidence document. [1]

2021 October-November · Paper 41 · Q2(e)

Programming paradigms · 8 marks · official answer ready

(e) The text file Pictures.txt stores the data for the pictures in the order: description, width, height, colour. For example, for the first picture in the text file: Flowers is t…

2021 October-November · Paper 41 · Q2(f)

Programming paradigms · 2 marks · official answer ready

(f) The main program calls the function ReadData(). Write the main program. Save your program. Copy and paste the program code into part 2(f) in the evidence document. [2] 6

2021 October-November · Paper 41 · Q2(g)

Programming paradigms · 7 marks · official answer ready

(g) The main program needs to ask the user to input their requirements for a picture. The user will enter the colour of the frame, the maximum width, and the maximum height of the…