Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help writing a program that follows these instructions written in C++ that asks a user for an input file and then informs them

I need help writing a program that follows these instructions written in C++ that asks a user for an input file and then informs them of the output file. I've attached the exercise instructions as it's hard to explain in other words. I would very much appreciate it if you could add comments to the code so that I may understand it and compare it to my own.

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Exercise 2: File Merge of Sorted Files Previous Master File (Master - input) Transaction File (input) New Master (output) Diagnostic output (cout): Unmatched record for account \# 400 . Unmatched record for account \# 1000 . High Level Design: detect the EOF by using the FAIL bit! Open all files. In an outer loop read input files, and write output file and diagnostic output. Case 1: finish old master file before end of transaction file (action: rest of transaction file goes to diagnostic output); break outer loop. Case 2: finish reading transaction file before end of old master file (action: write rest of old master file to new master file). Case 3a: transaction account \# == old master account \#; match found (action: write updated record to new master file; read next transaction entry and read next old master entry). Case 3b: transaction account \# > master account \# (action: inner loop; see below). Case 3c: transaction account \# old master account \# Write old master record to new master file. While not matched and transaction account \# > old master record Read next master record. If EOF, break inner loop. If transaction account \# == old master account #, then match = true. Else write update old master record to new master file. End inner while loop. If match then Update master record and write to new master file Read next transaction record. Read next old master record. Else Write transaction record to diagnostic output Read next transaction record. End if. etailed Design: detect the EOF by using the FAIL bit! input files, and exit on error. pen output file. ead first transaction record. ead first master record. hile not done // outer loop is exited by breaks If old master file is at EOF, then // case 1 Write rest of transaction records to the diagnostic output. Break. End if. If transaction file is at EOF, then // case 2 Write rest of old master records to new master file. Break. End if. If transaction account #== old master account #, then // match found, 3a Update old master record and write to new master file. Else if transaction account \# > old master account \#, // search for match, 3b Write old master record to new master file. While transaction account \# > old master account number AND NOT matched. // inner while loop Read old master record. If EOF break // inner loop If transaction account #== old master account number, then match = true. Else Write old master record to new master file. End if else. End while. // end inner loop If match == true, then Update master record and write to new master file. Read next transaction record. Read next master record. Else Write account record number to diagnostic output. Read next account record. End if. End if. Else / / transaction account \#

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

How Do I Use A Database Research Tools You Can Use

Authors: Laura La Bella

1st Edition

1622753763, 978-1622753765

More Books

Students also viewed these Databases questions