Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I'm having problems with finishing the code we started in class. I'm not a CS major, so I'm too invested in expending a lot of

I'm having problems with finishing the code we started in class. I'm not a CS major, so I'm too invested in expending a lot of time to finish this up. Any help will be appreciated.

#include #include

using namespace std;

const int NUM_PLAYERS = 25; const int MAX_COLS = 6; // Number of categories in players statistics

void get_average(int [][MAX_COLS], int, int [], int ); void get_min_index(int [][MAX_COLS], int, int [], int );

int main() { int pscores[NUM_PLAYERS][MAX_COLS]; int avg[MAX_COLS]; // Array passed as argument to get_average. Avg values are stored in this array int minim[MAX_COLS]; // Array passed as argument to get_min_index. Avg values are stored in this array string pname[NUM_PLAYERS], temp; int i, num, score, min_index; int row, col; ifstream infile;

infile.open("nbastats.txt"); if (!infile){ cout << "Invalid file name "; return -1; } // Skip the header line getline(infile, temp);

// Read the rest of the data and store them in the arrays for (row = 0; row < NUM_PLAYERS; row++){ // ROW BY ROW infile >> pname[row]; // First read the player name // Now read the stats for the player read above for (col = 0; col < MAX_COLS; col++){ infile >> pscores[row][col]; } }

// call the functions to calculate average and min for each category get_average(pscores, NUM_PLAYERS, avg, MAX_COLS ); get_min_index(pscores, NUM_PLAYERS, minim, MAX_COLS );

// Write the code to display the result

}

void get_average(int scores[][MAX_COLS], int s_size, int avg[], int a_size ) { // This function should calculate the average of each category of players statistics // Store the results in avg[] // s_size contains the number of rows of scores[][] // a_size is the size of avg[] //write your code below

}

void get_min_index(int scores[][MAX_COLS], int s_size, int minimum[], int m_size ) { // This function should find the index of the minimum value in each category of players statistics // Store the results in minimum[] // s_size contains the number of rows of scores[][] // m_size is the size of avg[] // Write you code below

}

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

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Database Processing

Authors: David M. Kroenke

12th Edition International Edition

1292023422, 978-1292023427

More Books

Students also viewed these Databases questions