Skip to content

Conversation

@devin-ai-integration
Copy link

Convert COBOL merge sort program to Java - MBA-18

Summary

Converts the COBOL program merge_sort/merge_sort_test.cbl to an equivalent Java program MergeSortExample.java while preserving exact functionality. The Java implementation replicates the three main procedures:

  1. createTestData() - Creates two test files with hardcoded customer records (6 records in file1, 5 records in file2)
  2. mergeAndDisplayFiles() - Merges files sorted by ascending customer ID, writes to merge-output.txt, displays records
  3. sortAndDisplayFile() - Sorts merged file by descending contract ID, writes to sorted-contract-id.txt, displays records

Key implementation details:

  • CustomerRecord class with 5 fields: customer ID (5 digits), last name (50 chars), first name (50 chars), contract ID (5 digits), comment (25 chars)
  • Fixed-width string formatting using String.format() and padding to match COBOL output
  • Java Collections framework with Comparator classes for sorting
  • File I/O using BufferedReader/PrintWriter with proper error handling

Review & Testing Checklist for Human

  • Verify test data accuracy - Compare the hardcoded customer records in Java against the COBOL source to ensure all IDs, names, contract IDs, and comments match exactly
  • Test output formatting - Run both programs and compare console output character-by-character to ensure fixed-width formatting is identical
  • Verify sorting correctness - Confirm merge operation sorts by ascending customer ID (1,3,5,10,24,25,30,50,75,85,999) and final sort is by descending contract ID (12323,8765,7725,5423,5050,4567,3331,1610,1175,653,247)
  • End-to-end execution test - Run javac MergeSortExample.java && java MergeSortExample and verify all 5 output files are created with correct content

Notes

- Implement MergeSortExample.java with exact functionality of merge_sort_test.cbl
- Create CustomerRecord class with 5 fields (customer ID, last name, first name, contract ID, comment)
- Implement three main procedures: createTestData(), mergeAndDisplayFiles(), sortAndDisplayFile()
- Use Java Collections framework with Comparators for sorting
- Maintain identical file names and output formatting
- Preserve exact test data and processing logic from COBOL original

Addresses ticket MBA-18

Co-Authored-By: Arjun Mishra <arjunsaxmishra@gmail.com>
@devin-ai-integration
Copy link
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant