Describe, with an example, what is meant by an exception.
- (a)Describe, with an example, what is meant by an exception.[2]
- (b)A pseudocode algorithm searches for a customer record in a random file AccountRecord.dat.A user inputs the name of the customer. The records are stored using the user-defined data type TAccount. TYPE TAccount DECLARE AccountNumber : INTEGER DECLARE Name : STRING DECLARE Address : STRING DECLARE Telephone : STRING ENDTYPE If the record is found, it is output, otherwise an error message is displayed. Complete the file handling pseudocode. DECLARE Customer : TAccount DECLARE Location : INTEGER DECLARE MaxSize : INTEGER DECLARE FoundFlag : BOOLEAN DECLARE SearchCustomer : STRING MaxSize ← 1000 OPENFILE Location ← 1 OUTPUT "Enter the customer's name" FALSE AND Location <= MaxSize "AccountRecord.dat", GETRECORD "AccountRecord.dat", Customer IF SearchCustomer = Customer. Name THEN OUTPUT "Customer found: " OUTPUT Customer // output customer record FoundFlag ← TRUE ENDIF Location ← Location + 1 ENDWHILE IF NOT FoundFlag THEN OUTPUT " " ENDIF[7]
Mark scheme
Marking points from the official mark scheme (Oct/Nov 2023). The mark or mark type is shown in brackets.
- [1] An exception is an event that occurs during the execution of a program that disrupts the normal flow of instructions / causes the program to halt execution
- [1] Hardware failure // hard disk crash
- [1] Programming error // trying to access out-of-bounds array element // divide by zero error // runtime error
- [1] User error // typing incorrect filename / data type
- [1] OPENFILE "AccountRecord.dat" FOR RANDOM
- [1] FoundFlag ← FALSE
- [1] INPUT SearchCustomer
- [1] WHILE NOT FoundFlag AND Location <= MaxSize
- [1] SEEK "AccountRecord.dat", Location
- [1] GETRECORD "AccountRecord.dat", Customer
- [1] IF SearchCustomer = Customer. Name THEN
- [1] OUTPUT Customer
- [1] FoundFlag ← TRUE
- [1] OUTPUT "Customer does not exist."
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 →