A procedure CreateFiles() will take two parameters: : a string representing a file name an integer representing the number of files to be created. The procedure will create the number of text files specified. Each file is given a different name. Each file name is formed by concatenating the file name with a suffix based on the file number. The suffix is always three characters. For example, the call CreateFiles("TestData", 3) would result in the creation of the three files, TestData.001, TestData.002 and TestData.003. Each file will contain a single line. For example, file TestData.002 would contain the string: This is File TestData.002 Write pseudocode for CreateFiles(). Assume both parameters are valid and that the integer value is between 1 and 999, inclusive.
- (a)A procedure CreateFiles() will take two parameters: : a string representing a file name an integer representing the number of files to be created. The procedure will create the number of text files specified. Each file is given a different name. Each file name is formed by concatenating the file name with a suffix based on the file number. The suffix is always three characters. For example, the call CreateFiles("TestData", 3) would result in the creation of the three files, TestData.001, TestData.002 and TestData.003. Each file will contain a single line. For example, file TestData.002 would contain the string: This is File TestData.002 Write pseudocode for CreateFiles(). Assume both parameters are valid and that the integer value is between 1 and 999, inclusive.[6]
- (b)(i)Identify the type of module that should be used for CheckFiles().[1]
- (b)(ii)Write the module header for CheckFiles().[1]
- (b)(iii)State the file mode that should be used in CheckFiles().[1]
Mark scheme
Marking points from the official mark scheme (Oct/Nov 2023). The mark or mark type is shown in brackets.
- [6] Mark as follows:
- 1 Procedure heading, including parameters, and ending
- 2 Loop for NumFiles iterations
- 3 Attempt to create filename suffix using NUM_TO_STR() in a loop
- 4 Completely correct filename
- 5 OPENFILE in WRITE mode and subsequent CLOSE in a loop
- 6 WRITE initial first line to the file in a loop
- [1] Function
- [1] FUNCTION CheckFiles (NameRoot : STRING) RETURNS INTEGER
- [1] Read
Write your answer and get it marked
On Oracle Prep you can write or photograph your own answer and have it marked by AI against this mark scheme, with feedback on what you missed.
Sign up free →