Question: Exercise 1: Read the documentation carefully and complete program Chart2. Show what is printed. #include #include using namespace std; const int ROW_MAX = 8; const

Exercise 1: Read the documentation carefully and complete program Chart2. Show

what is printed.

#include

#include

using namespace std;

const int ROW_MAX = 8;

const int COL_MAX = 10;

typedef int ItemType;

typedef ItemType ChartType[ROW_MAX][COL_MAX];

void GetChart(ifstream&, ChartType, int&, int&);

// Reads values and stores them in the chart.

void PrintChart(ofstream&, const ChartType, int, int);

// Writes values in the chart to a file.

void largest(ifstream &, int &, int&);

int main ()

{

ChartType chart;

int rowsUsed;

int colsUsed;

ifstream dataIn;

ofstream dataOut;

dataIn.open("chart2.dat.txt");

dataOut.open("chart2.out");

if(dataIn.good())

{

GetChart(dataIn, chart, rowsUsed, colsUsed);

PrintChart(dataOut, chart, rowsUsed, colsUsed);

}

else

cout << "Error in opening files" << endl;

return 0;

}

//***************************************************

void GetChart(ifstream& data, ChartType chart,

int& rowsUsed, int& colsUsed)

// Pre: rowsUsed and colsUsed are on the first line of

// file data; values are one row per line

// beginning with the second line.

// Post: Values have been read and stored in the chart.

{

ItemType item;

data >> rowsUsed >> colsUsed;

for (int row = 0; row < rowsUsed; row++)

for (int col = 0; col < colsUsed; col++)

{

//Fill IN Code

}

}

//****************************************************

void PrintChart(ofstream& data, const ChartType chart,

int rowsUsed, int colsUsed)

//Pre: The chart contains valid data.

//Post: Values in the chart have been sent to a file by row,

//one row per line.

{

FILL IN Code to print chart by row.

}

Exercise 2: Add a function that prints the largest value in array variable chart. Rerun

the program.

Largest value is __________.

TXT File:

4 5 3 1 4 1 5 2 3 6 7 1 7 8 8 8 8 9 8 7 6 5

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!