(File Matching) Exercise 11.3 asked the reader to write a series of single statements. Actually, these statements form the core of an important type of file-processing
As transactions occur (i.e., sales are made and cash payments arrive in the mail), they’re entered into a file. At the end of each business period (i.e., a month for some companies, a week for others and a day in some cases) the file of transactions (called “trans.dat” in Exercise 11.3) is applied to the master file (called “oldmast.dat” in Exercise 11.3), thus updating each account’s record of purchases and payments. After each of these updates runs, the master file is rewritten as a new file (“newmast.dat”), which is then used at the end of the next business period to begin the updating process again.
File-matching programs must deal with certain problems that do not exist in single-file programs. For example, a match does not always occur. A customer on the master file might not have made any purchases or cash payments in the current business period, and therefore no record for this customer will appear on the transaction file. Similarly, a customer who did make some purchases or cash payments might have just moved to this community, and the company may not have had a chance to create a master record for this customer.
Use the statements written in Exercise 11.3 as the basis for a complete file-matching accounts receivable program. Use the account number on each file as the record key for matching purposes. Assume that each file is a sequential file with records stored in increasing account number order.
When a match occurs (i.e., records with the same account number appear on both the master file and the transaction file), add the dollar amount on the transaction file to the current balance on the master file and write the “newmast.dat” record. (Assume that purchases are indicated by positive amounts on the transaction file, and that payments are indicated by negative amounts.) When there’s a master record for a particular account but no corresponding transaction record, merely write the master record to “newraast.dat”. When there’s a transaction record but no corresponding master record, print the message “Unmatched transaction record for account number...“ (fill in the account number from the transaction record).
Want to see the full answer?
Check out a sample textbook solutionChapter 11 Solutions
C How to Program (8th Edition)
Additional Engineering Textbook Solutions
C++ How to Program (10th Edition)
Starting Out with Java: From Control Structures through Objects (6th Edition)
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Computer Science: An Overview (12th Edition)
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Java How To Program (Early Objects)
- 3. What is the function of the Unload Me statement?arrow_forwardPlease solve and show steps, work, and information related to this problem. Thank you. The following C++ code performs a set of various arithmetic operations using both pointers and references: Fill in a memory table that shows the final values for both function a and function b. Indicate the final values of each parameter, passed in variable(s), and the return value of the function. Provide a separate copy of this memory table for each function.arrow_forwardanswer in c program -Write a function to input patient information and store it in a file. One of the parameters of the function must be no. of patients to input and another one the name of the file to store the information. Write a function to output patient information that are stored in a file. One of the parameters of the function must be no. of patients to output and another one the name of the file where the patients’ information is stored Write a function to sort the patients’ information based on their status.arrow_forward
- answer in c program -Write a function to output patient information that are stored in a file. One of the parameters of the function must be no. of patients to output and another one the name of the file where the patients’ information is stored.arrow_forward4. What does this function return? Which principle does it illustrate?arrow_forwardThe following is the difference between void and NULL pointers: Use relevant examples to back up your statement.arrow_forward
- ANSWER IN C PROGRAM -Write a function to input patient information and store it in a file. One of the parameters of the function must be no. of patients to input and another one the name of the file to store the information.arrow_forward5.1) For each of the following statements, show whether the statement is correctly executed or not (assume that the statements are executed in order, which means that if a statement is correctly executed, its effect is reflected in the following statement). If you say the statement is not executed, explain why. a. INSERT INTO Students VALUES (3, ‘Ellen’); b. INSERT INTO Students VALUES (6, ‘Ellen’); c. INSERT INTO Register VALUES (1, 2); d. INSERT INTO Courses VALUES (5, ‘Systems’); e. INSERT INTO Register VALUES (6, 5); f. INSERT INTO Register VALUES (3, 5);arrow_forwarduse code to develop a C program that gets a source file name from a user. If the file does not exist, it will generate a proper error and exits. If the file exists, it also gets the name of two files from the user, say destination1 and destination2. These files don't need to exist as they are files that need to be written to. The program then reads the source file line by line. If the line starts with an uppercase and ends with a lower case, it copies that line to dest1 (first destination file) If the line starts with a lowercase and ends with a dot ('.'), it copies that line to dest2 (second destination file) If neither of the above hold, the program discards that line (doesn't copy it anywhere) The program then displays a report mentioning how many lines were copied into each destination file. Don't forget to close all the files. Example: Assume that the source file is (<NL> = new line, <EOF> end of file): Souce: "myfile.txt" This is my first line<NL>…arrow_forward
- 3. A. The following transfer statements specify a memory. Explain the memory operation in each case. i. M[AR] R5 ii. R1 M[R5] iii. R2 M[AR]arrow_forwardModify this program to use namespaces and separate compilation. using c++-Put the class definition and other function declarations Programming Projects 517 in one file.-Place the implementations in a separate file.-Distribute the namespace definition across the two files.-Place the demonstration program in a third file.-To provide access to names in namespaces, you may use local using declarations such as using std::cout; or use local using directives such as using namespace std; inside a block, or qualify names using the names of namespaces, such as std::cout.-You may not use global namespace directives such as the following which are not in a block and apply to the entire file: using namespace std;" code #include <iostream>#include<string>using namespace std; class PFArrayD{public:PFArrayD( );//Initializes with a capacity of 50.PFArrayD(int capacityValue);PFArrayD(const PFArrayD& pfaObject);void addElement(double element);//Precondition: The array is not…arrow_forwardModify this program to use namespaces and separate compilation. using c++-Put the class definition and other function declarations Programming Projects 517 in one file.-Place the implementations in a separate file.-Distribute the namespace definition across the two files.-Place the demonstration program in a third file.-To provide access to names in namespaces, you may use local using declarations such as using std::cout; or use local using directives such as using namespace std; inside a block, or qualify names using the names of namespaces, such as std::cout.-You may not use global namespace directives such as the following which are not in a block and apply to the entire file: using namespace std;" code #include <iostream>#include<string>using namespace std; class PFArrayD{public:PFArrayD( );//Initializes with a capacity of 50.PFArrayD(int capacityValue);PFArrayD(const PFArrayD& pfaObject);void addElement(double element);//Precondition: The array is not…arrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning