Exercises — Chapter 14: Advanced File Techniques

Exercise 14.1: Simple Balanced-Line Update

Difficulty: Intermediate

Implement the balanced-line algorithm for a student records system.

Requirements:

  1. Master file (sorted by Student ID): Student ID, Name, Major, GPA, Credits, Status
  2. Transaction file (sorted by Student ID): Student ID, Transaction Type, Data - Type 'A': Add new student (data = Name, Major) - Type 'U': Update GPA (data = new GPA value) - Type 'G': Graduate (change status to 'G') - Type 'D': Drop (change status to 'D')

  3. Output files: - New master file (updated student records) - Exception file (rejected transactions with reason codes) - Summary report

  4. Test scenarios to include: - Master-only records (no transactions) - Single transaction per master - Multiple transactions per master (e.g., update GPA then graduate) - Add transaction (no matching master) - Transaction for non-existent student - Duplicate add attempt

  5. Create test data with 10 master records and 15+ transactions.


Exercise 14.2: Two-File Merge

Difficulty: Beginner-Intermediate

Write a program that merges two sorted files into one.

Requirements:

  1. File A: Employee records from East region (sorted by Employee ID)
  2. File B: Employee records from West region (sorted by Employee ID)
  3. Output: Merged file with all employees in Employee ID order

  4. Handle: - Records unique to File A - Records unique to File B - Records with the same Employee ID in both files (flag as duplicate in report)

  5. Produce a merge summary showing counts from each source and total output.


Exercise 14.3: Single-Level Control Break Report

Difficulty: Intermediate

Build a control break report for account data.

Requirements:

  1. Input: Account file sorted by Branch Code, Account Number
  2. Report layout: - Header with report title and date - Detail lines: Branch, Account Number, Name, Balance - Branch subtotals: count of accounts, total balance, average balance - Grand totals: total accounts, total balance, average balance
  3. Page break handling: Start a new page after 50 detail lines
  4. Format balances with commas and dollar signs

Exercise 14.4: Multi-Level Control Break

Difficulty: Advanced

Extend Exercise 14.3 to a three-level control break.

Requirements:

  1. Input: Account file sorted by Region, Branch, Account Type
  2. Break levels: - Account Type subtotal (within branch) - Branch subtotal (within region) - Region subtotal - Grand total
  3. Each level shows: count, total balance, percentage of parent total
  4. Higher-level breaks must trigger all lower-level breaks
  5. Add sort-order verification (abort if input is not properly sorted)

Exercise 14.5: File Comparison and Reconciliation

Difficulty: Intermediate

Write a reconciliation program for two extracts of the same data.

Requirements:

  1. File A: Yesterday's account extract (Account Number, Name, Balance)
  2. File B: Today's account extract (same layout)
  3. Output reconciliation report showing: - Records in both files with no changes - Records in both files with balance changes (show old and new balance) - Records in File A only (accounts that disappeared) - Records in File B only (new accounts) - Summary counts for each category
  4. Calculate: total balance change from yesterday to today

Exercise 14.6: Checkpoint/Restart Implementation

Difficulty: Advanced

Add checkpoint/restart capability to a long-running program.

Requirements:

  1. Processing program: Read a large sequential file, perform calculations on each record, write results to an output file
  2. Checkpoint every 1,000 records: - Save: last key processed, record count, running totals, timestamp - Write checkpoint record to a checkpoint file
  3. Restart logic: - Check for existing checkpoint file on startup - If found, restore state and position to restart point - If not found, start from beginning
  4. Test by: - Running with 5,000 records — verify it completes normally - Simulating a failure at record 3,000 (add a forced STOP RUN) - Restarting — verify it resumes from the last checkpoint - Verify final output is identical to the non-interrupted run

Exercise 14.7: MedClaim Claims Matching

Difficulty: Advanced

Build a simplified claims adjudication program.

Requirements:

  1. Claims file (sequential, sorted by Claim ID): - Claim ID, Member ID, Provider ID, Procedure Code, Billed Amount, Service Date

  2. Provider file (indexed, VSAM KSDS): - Provider ID (key), Name, Specialty, Contract Status, Max Allowed Amount

  3. Member file (indexed, VSAM KSDS): - Member ID (key), Name, Plan Code, Effective Date, Term Date

  4. Processing: - For each claim, look up provider (random access) - Look up member (random access) - Validate: provider is in-network, member is active, service date within coverage period, billed amount <= max allowed - Write approved claims, denied claims (with reason), and processing report

  5. Create test data: 50 claims, 20 providers, 30 members. Include scenarios for all denial reasons.


Exercise 14.8: GlobalBank Mini-Project — Daily Batch Cycle

Difficulty: Advanced (Project)

Build a simplified version of GlobalBank's daily batch cycle as a series of coordinated programs.

Step 1: SORT-TXN — Sort the daily transaction file by account number

Step 2: DAILY-UPDATE — Balanced-line update of account master (old master + sorted transactions = new master + exceptions)

Step 3: BRANCH-RPT — Control break report of the new master file by branch

Step 4: RECONCILE — Compare old master + transactions against new master to verify correctness

Requirements for each step: - File status checking on all I/O - Comprehensive counters and summary report - Error handling that writes to exception files, never silently skips - Clear paragraph naming and documentation

This exercise prepares you for the full banking system capstone in Chapter 43.