Question: a) When designing and writing program code, explain what is meant by: An exception Exception handling. b) A program is to be written

a) When designing and writing program code, explain what is meant by:
– An exception
– Exception handling.
b) A program is to be written to read a list of exam marks from an existing text file into a 1D array.
Each line of the file stores the mark for one student.
State three exceptions that a programmer should anticipate for this program.
c) The following pseudocode is to read two numbers.

01 DECLARE Num1 INTEGER 02 DECLARE Num2 : INTEGER 03 DECLARE Answer

The programmer writes the corresponding program code.
A user inputs the number 53 followed by 6. The following output is produced:

: INTEGER 04 TRY 05 OUTPUT "First number..." 06 INPUT Numl 07

i) State the pseudocode line number which causes the exception to be raised.
ii) Explain the purpose of the pseudocode on lines 11 and 12.

01 DECLARE Num1 INTEGER 02 DECLARE Num2 : INTEGER 03 DECLARE Answer : INTEGER 04 TRY 05 OUTPUT "First number..." 06 INPUT Numl 07 OUTPUT "Second number..." %3D 08 INPUT Num2 09 Answer e Numl / (Num2 - 6) 10 OUTPUT Answer 11 EXCEPT ThisException : EXCEPTION 12 OUTPUT ThisException.Message 13 FINALLY 14 // remainder of the program follows 29 30 ENDTRY

Step by Step Solution

3.51 Rating (168 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Exception and Exception Handling Exception An exception is an error that occurs during the execution ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Cambridge International AS & A Level Computer Science Questions!