Question: C++ This is all the information given File Processing Given the following program, show the changes that would be necessary to convert to random file

C++

This is all the information given

File Processing

Given the following program, show the changes that would be necessary to convert to random file input and allow users to select (from a keyboard prompt) a list of records they would like to print. (e.g., user entry => 2 5 6 7 would print records 2,5,6, and 7)

// Reading and printing a sequential file

#include

#include

#include

#include

#include

using namespace std;

void outputLine( int, const string &, double );

int main()

{

// ifstream constructor opens the file

ifstream inClientFile( "clients.txt", ios::in );

if ( !inClientFile ) {

cerr << "File could not be opened" << endl;

exit( EXIT_FAILURE );

}

int account;

string name;

double balance;

cout << left << setw( 10 ) << "Account" << setw( 13 )

<< "Name" << "Balance" << endl << fixed << showpoint;

while ( inClientFile >> account >> name >> balance )

outputLine( account, name, balance );

}

void outputLine( int account, const string &name, double balance )

{

cout << left << setw( 10 ) << account << setw( 13 ) << name

<< setw( 7 ) << setprecision( 2 ) << right << balance << endl;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!