10.
a) A recursive procedure is a method of solving a problem where the solution
depends on solutions to smaller instances (problems) of the same problem. In
programming, a recursive function calls itself with modified arguments to break
down the problem into simpler sub problems until it reaches a base case, which is
a condition that stops the recursion.
Components of a Recursive Procedure
Base Case: This is the condition under which the recursion stops. It prevents
infinite recursion and provides a simple, direct answer for the simplest instances
of the problem.
Recursive Case: This is where the function calls itself with modified arguments.
The recursive case should bring the problem closer to the base case.
10. b)
FUNCTION Factorial(n)
// Base case
IF n = 0 THEN
RETURN 1
END IF
// Recursive case
RETURN n * Factorial(n - 1)
END FUNCTION
3. a)
Field Name Type Size Validation
CustomerID String 10 characters Unique identifier
for the customer;
must be unique,
non-empty
CustomerName String 100 characters Non-empty,
max letters and
allowed special
characters only
Address String 200 characters Non-empty, full
max postal address
MeterCode String 8 digits Must be exactly 8
digits including a
valid check digit
MeterCodeCheckDigi Integer 1 digit (derived Must match the
t from MeterCode) last digit of
MeterCode
according to
check digit logic
Readings List of Reading Up to unlimited Each reading
readings corresponds to a
3-month interval
isEstimated Boolean True/False Indicates if the
latest reading is
estimated or
actual reading