Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in c programming language . i also included my code . im getting errors on line 35 . #include #include int main() { int masterAccount;

in c programming language . i also included my code . im getting errors on line 35 .
#include
#include
int main()
{
int masterAccount;
int transacAccount;
double masterBalance;
double transacBalance;
char masterName [30];
FILE *odfptr;
FILE *trfptr;
odfptr=fopen("oldmaster.dat","w" );
trfptr=fopen("transact.dat","w");
printf("sample data for oldmaster.dat: ");
int x ;
do
{
printf(" enter account , name , balance :");
scanf("%d%[^0-9-]% lf",&masterAccount, masterName,&masterBalance);
fprintf(odfptr,"%d %s %.2f ",masterAccount,masterName,masterBalance );
printf(" do you want to add another account? ");
printf(" 1. yes ");
printf(" 0. no ");
getchar();
scanf( " %d ", &x );
} while (x!=0);
fclose(odfptr);
printf (" sample data for transact.dat: ");
int c ;
do
{
printf("enter account and transact amount:");
scanf( " %d %lf", &transacAccount, &transacBalance );
fprintf(trfptr,"%d %.2f ", transacAccount,transacBalance );
printf( " Do you want to add more transactions ? ");
printf(" 1. yes ");
printf(" 0. no ");
getchar();
scanf( " %d ", &c );
}
while (c!=0);
fclose (trfptr);
}
image text in transcribed
image text in transcribed
create some test ample account data: 11.7 ture reference. am) Write a simple program to creat (Creating Data for a File-Matching Program) checking out the program of Exercise 11.8. Use the following sample acco data for checking out the progra Master File: Account number Name Balance 100 300 500 700 Alan Jones Mary Smith Sam Sharp Suzy Green 348.17 27.19 0.00 -14.22 Transaction File: Account number Dollar amount 100 300 27.14 62.11 100.56 82.17 400 900 Exercises 473 11.8 (File Matching Exercise 11.3 asked the reader to write a series of single statements. Actu- ally, these statements form the core of an important type of file-processing program, namely, a file- matching program. In commercial data processing, it's common to have several files in each system. In an accounts receivable system, for example, there's generally a master file containing detailed information about each customer such as the customer's name, address, telephone number, out- standing balance, credit limit, discount terms, contract arrangements and possibly a condensed his- tory of recent purchases and cash payments. 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.c., 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 pro- grams. 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 pur- chases 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-marching 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. werely write the master record to "newmast.dat". When there's a transaction record but no ponding master record, print the message "Unmatched transaction record for account numbe hill in the account number from the transaction record). 11.9 (Testing the File- test data created in (Testing the file-Matching Exercises) Run the program of Exercise 11.8 using the fil data created in Exercise 11.7. Check the results carefully. B ible Gactually common

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_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions