Further programming
152 questions. Open a question to solve it and check the official answer.
File processing and exception handling · 2 marks · official answer ready
(a) Describe how program termination due to an exception can be avoided. ..........................................................................................................…
Programming paradigms · 4 marks · official answer ready
(i) Write program code to declare the class Train and its constructor. Do not declare the other methods. All attributes should be private. Use your programming language appropriat…
Programming paradigms · 3 marks · official answer ready
(ii) The methods GetTrainIDNumber() and GetRoute() return the appropriate attribute. Write program code for GetTrainIDNumber() and GetRoute() Save your program. Copy and paste the…
Programming paradigms · 2 marks · official answer ready
(b) The program is tested with four trains: train ID number route 12ADV 134 33ART 20 9FKF 3 21VBC 24 Write program code to declare an instance of Train for each of the four trains…
Programming paradigms · 3 marks · official answer ready
(i) Write program code to declare the class Station and its constructor. Do not declare the other methods. All attributes should be private. Use your programming language appropri…
Programming paradigms · 4 marks · official answer ready
(ii) The method AddTrain() takes a Train parameter. The method compares the attributes NumberTrains and NumberPlatforms to identify if there is a platform available (a platform cu…
Programming paradigms · 6 marks · official answer ready
(iii) The method GetTrains() returns the string "There are no trains" if there are no trains at the station platforms. If there are trains at the station platforms, the method ret…
Programming paradigms · 2 marks · official answer ready
(i) Write program code to amend the main program to declare an instance of Station for each of the two stations. Save your program. Copy and paste the program code into part 2(d)(…
Programming paradigms · 4 marks · official answer ready
(ii) The four trains attempt to stop at the following stations in the order given: • Train 12ADV, station STH • Train 33ART, station STH • Train 9FKF, station STH • Train 21VBC, s…
Programming paradigms · 2 marks · official answer ready
(iii) Test your program. Take a screenshot of the output(s). Save your program. Copy and paste the screenshot(s) into part 2(d)(iii) in the evidence document. [2] 9
Programming paradigms · 2 marks
(a) The class Record stores data about the records: Record Key : Integer stores the integer key field for the data Data : String stores the string data Constructor() initialises K…
Programming paradigms · 2 marks
(b) The procedure InitialiseHashTable() initialises each element in the array to an empty or null record. Write program code to declare the global 2D array HashTable and the proce…
Programming paradigms · 2 marks
(c) The function Hash(): • takes an integer key field as a parameter • calculates and returns the hash value of the key field. The hash value is the result from the formula: key M…
Programming paradigms · 4 marks
(d) The procedure InsertData(): • takes an object of type Record as a parameter • calculates the hash value for the parameter using the appropriate function • stores the parameter…
Programming paradigms · 5 marks
(e) The file "HashTableData.txt" stores 200 key values and string data items in the format: key,string For example, the first row in the text file is: 528,permission The key is 52…
Programming paradigms · 5 marks
(f) The function GetRecord(): • takes an integer key field as a parameter • calculates the hash value for the key field using the appropriate function • searches the hash table fo…
Programming paradigms · 3 marks
(i) Write program code for the main program. Save your program. Copy and paste the program code into part 3(g)(i) in the evidence document. [3]
Programming paradigms · 2 marks
(ii) Test your program with the following five inputs in the order given: 528 1128 1828 1062 39 Take a screenshot of the output(s). Save your program. Copy and paste the screensho…
Programming paradigms · 4 marks · official answer ready
(i) Write program code to declare the class Bird and its constructor. Do not declare the other methods. All attributes should be private. Use your programming language appropriate…
Programming paradigms · 2 marks · official answer ready
(ii) The method GetSpecies() returns the species of the bird. Write program code for GetSpecies() Save your program. Copy and paste the program code into part 1(a)(ii) in the evid…
