IGCSE Computer Science 0478/23 Problem-solving and Programming October/November 2022 Notes

Pre-release Material: Window Cleaning Company Management System

  • System Purpose: A program designed for a window cleaning company to store service details for each job, generate itemised bills for customers, and analyze service popularity.

  • Service Pricing and Calculation Order: Costs are applied in the specific order listed in the table.

    • Basic window clean (outside, one floor, up to five windows): 10.0010.00

    • Additional windows (up to and including five more): 5.005.00

    • Service on two floors: 10%10\% extra

    • Service on three floors: 15%15\% extra

    • Inside cleaning included: 25%25\% extra

    • Polish all windows cleaned: 5%5\% extra

    • Special solar panel clean: 20.0020.00

  • Calculation Example: A customer with six windows over three floors.

    • Base cost (55 windows): 10.0010.00

    • Additional windows (11 window): 5.005.00

    • Subtotal: 10.00+5.00=15.0010.00 + 5.00 = 15.00

    • Three floors adjustment (15%15\% extra): 15.00×1.15=17.2515.00 \times 1.15 = 17.25

    • Total Bill: 17.2517.25

  • General Programming Requirements:

    • Validation on all data entry.

    • Meaningful names for all variables, constants, and identifiers.

    • Clear and understandable outputs and error messages.

System Implementation Tasks

  • Task 1 – System Setup and Data Storage:

    • Customer names and addresses must be stored in a single-dimensional array.

    • The array index of the customer's entry serves as the unique itemised bill number.

    • Service requirements are stored in separate arrays (one for each service) at the same index as the customer details.

  • Task 2 – Service Recording and Billing:

    • The program must display available services and their respective costs.

    • Functionality to input and store customer details and specific service requirements.

    • Automatic calculation of the total cost based on the established pricing rules.

    • Display of the itemised bill, including the unique bill number and total cost.

    • Provision for repeating the process for multiple customers.

  • Task 3 – Statistics and Analysis:

    • The system must identify the most popular and least popular services, excluding basic cleaning and additional windows.

    • Output requirements for these two services include:

      • Service name.

      • Status (most or least popular).

      • Frequency of use expressed as a percentage of the total bills stored: Percentage=(Service CountTotal Bills)×100\text{Percentage} = (\frac{\text{Service Count}}{\text{Total Bills}}) \times 100

Programming Principles and Problem Solving

  • Constants in Programming:

    • Example identifiers: BasicClean, SolarPanelCost, TwoFloorPremium.

    • Values: BasicClean = 10.0010.00, SolarPanelCost = 20.0020.00, TwoFloorPremium = 0.100.10.

    • Rationale for constants: Prices or percentage rates remain static throughout the program's execution, preventing accidental value changes and making the code easier to update if rates change globally.

  • Array Management for Customer Details:

    • Name: CustomerDetails or CustAddress.

    • Data Type: String (to accommodate alphanumeric address data).

    • Sample Data: "J. Smith, 22 Acacia Avenue, Anytown".

  • Selection Logic for Floor Levels:

    • To ensure only one floor option (two vs. three) is selected, a program can use a single variable (e.g., NumFloors) and validate it to accept only values 1,2, or 31, 2, \text{ or } 3.

    • Alternatively, an IF...THEN...ELSE IF structure ensures that if the condition for "two floors" is met, the "three floors" condition is skipped.

    • Boolean flags can also be used with mutual exclusivity logic (e.g., IF TwoFloors = TRUE THEN ThreeFloors = FALSE).

Statistics Algorithm Details (Task 3)

  • Processing Popularity:

    • Counters are initialized for each eligible service (e.g., InsideCount, PolishCount, SolarCount).

    • The program iterates through the service arrays using a FOR loop from index 1 to the total number of bills.

    • Within the loop, IF statements check if a service was selected (e.g., IF Inside[Index] = TRUE THEN InsideCount ← InsideCount + 1).

    • After the loop, the counts are compared using selection statements to find the maximum and minimum values.

    • The percentage is calculated by dividing each count by the total bill count and multiplying by 100100.

Pseudocode and Data Entry Algorithms

  • Array Initialization:

    • FOR Count ← 1 TO 50 sets all elements in a storage array to zero to clear previous data.

  • Range Validation and Frequency Counting:

    • The algorithm accepts inputs between 3535 and 5050 inclusive.

    • Termination conditions: Input of 1-1 OR entering 5050 valid numbers.

    • Frequency tracking: Reading[Value] ← Reading[Value] + 1 increments the counter at the index corresponding to the input value.

  • Output Modification:

    • to change an output from ascending (lowest first) to descending (highest first), the FOR loop or REPEAT loop counter must be decremented (e.g., FOR Count ← 50 TO 35 STEP -1).

Validation and Check Digits

  • Check Digit Calculation Process:

    1. Sum the first five digits of the identification number.

    2. Divide the total by 1010.

    3. Find the remainder.

    4. The remainder serves as the sixth (check) digit.

  • Calculation Example: For ID 69321.

    • Step 1 (Sum): 6+9+3+2+1=216 + 9 + 3 + 2 + 1 = 21

    • Step 2 (Division): 21÷10=221 \div 10 = 2 remainder 11

    • Step 3 (Resulting ID): 693211

  • Validation Identification:

    • ID 722855: Sum is 7+2+2+8+5=247+2+2+8+5 = 24. Remainder is 44. Check digit 55 is incorrect.

    • ID 231200: Sum is 2+3+1+2+0=82+3+1+2+0 = 8. Remainder is 88. Check digit 00 is incorrect.

  • Limits of Simple Sum Check Digits:

    • This specific algorithm fails to detect transposition errors (e.g., entering 512 instead of 152) because the sum remains identical.

    • A more robust algorithm involves weighted values (e.g., multiplying each digit by its position before summing) like in ISBN or EAN systems.

  • Additional Validation Checks:

    • Length Check: Ensures exactly six digits are entered.

    • Type/Character Check: Ensures only numeric digits are entered.

    • Range Check: Ensures the ID falls within a predefined numerical range.

Process Flow and Inventory Logic

  • Wheelbarrow Stock Management:

    • Initial values: Stock ← 10, Total ← 0.

    • When a sale is recorded (Sale = "Y"), Stock decreases by 11 and Total sales increase by 11.

    • Reordering threshold: If Stock < 5, then Stock ← Stock + 10 (simulating new stock delivery).

    • Process ends when Sale = "N".

  • Expanding Inventory Systems: To allow multiple unit sales, the input should change from "Y/N" to an integer quantity. The algorithm would then subtract the quantity from Stock and add the quantity to Total, provided Quantity ≤ Stock.

Database Management

  • Table Structure (MUSEUM):

    • ItemCode: Unique identifier for items (e.g., ART0005).

    • Description: Text description.

    • InStore: Boolean/Character representing if the item is present (Y/N).

    • Century: Numerical record of origin time (e.g., 18).

    • Country: String of origin country.

  • Primary Keys: ItemCode is the ideal primary key because it is unique to every record, ensuring no two items have the same identifier.

  • Query-By-Example (QBE): To find specific items not in store:

    • Fields selected: Description, Country.

    • Filter (Criteria) on InStore field: "N" or ≠ "Y".

    • Show property: True for Description and Country; False for InStore.