(File Matching Test Data) After writing the program of Exercise 8.7, write a simple pro- gram to create some test data for checking out the program. Use the following sample account data:

```
#include
#include
#include
#include
#include
using namespace std;
int main()
{
const int ITEMS = 4;
// account number
const int accountNumbers[ ITEMS ] = { 100, 300, 500, 700 };
// names of account holders
const string names[ ITEMS ] =
{ "Alan Jones", "Mary Smith", "Sam Sharp", "Suzy Green" };
// balances of account holders
const double balances[ ITEMS ] = { 348.17, 27.19, 0.00, -14.22 };
// account transactions
const double transactionAmounts[ ITEMS ] =
{ 27.14, 62.11, 100.56, 82.17 };
// intialize output streams and open output files
ofstream outOldMaster( "oldMast.txt" );
ofstream outTransaction( "trans.txt" );
// terminate program if master output file cannot be opened
if ( !outOldMaster )
{
cerr << "Unable to open oldmast.txt\n";
exit( 1 );
} // end if
// terminate application if output transactions file cannot be opened
if ( !outTransaction )
{
cerr << "Unable to open trans.txt\n";
exit( 1 );
} // end if
// write data to "oldmast.txt"
cout << fixed << showpoint << "Contents of \"oldmast.txt\":\n";
// create random master account balances and write to file
outOldMaster << fixed << showpoint;
for ( int i = 0; i < ITEMS; ++i )
{
outOldMaster << accountNumbers[ i ] << ' ' << names[ i ] << ' '
<< setprecision( 2 ) << balances[ i ] << '\n';
cout << accountNumbers[ i ] << ' ' << names[ i ] << ' '
<< setprecision( 2 ) << balances[ i ] << '\n';
} // end for
// write data to "trans.txt"
cout << "\nContents of \"trans.txt\":\n";
outTransaction << fixed << showpoint;
// create random transactions and write to file
for ( int i = 0; i < ITEMS; ++i )
{
outTransaction << accountNumbers[ i ] << ' ' << setprecision( 2 )
<< transactionAmounts[ i ] << '\n';
cout << accountNumbers[ i ] << ' ' << setprecision( 2 )
<< transactionAmounts[ i ] << '\n';
} // end for
} // end main
```
Contents of "oldmast.txt":
100 Alan Jones 348.17
300 Mary Smith 27.19
500 Sam Sharp 0.00
700 Suzy Green -14.22
Contents of "trans.txt":
100 27.14
300 62.11
500 100.56
700 82.17
Contents of oldMast.txt
100 Alan Jones 348.17
300 Mary Smith 27.19
500 Sam Sharp 0.00
700 Suzy Green -14.22
Contents of trans.txt
100 27.14
300 62.11
500 100.56
700 82.17
You might also like to view...
Images that are ____________________ may still require a payment, but it is usually a one-time fee.
Fill in the blank(s) with the appropriate word(s).
SQL Server data is stored, retrieved, and manipulated within a ____ architecture.
A. triangular B. flat C. node-outposts D. client-server
Graded-index fiber was developed to do which of the following?
A) Enable WDM applications B) Overcome pulse-dispersion problems C) Overcome OH peaks D) Increase bandwidth
You can create labels based on queries or tables.
Answer the following statement true (T) or false (F)