20.1 Programming paradigms
145 questions in this subtopic. Open a question to solve it and check the official answer.
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…
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…
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(…
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…
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
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…
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…
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.…
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…
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…
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…
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
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 …
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…
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…
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…
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]
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…
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
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…
