Question: Write a C++ program that reads data from a data file(season2017.txt) and stores the data in three parallel arrays of size 5. Once the data

Write a C++ program that reads data from a data file(season2017.txt) and stores the data in three parallel arrays of size 5. Once the data is loaded in the arrays, call a function, named listShow(), that displays the array elements in a tabular format, where each column is 15 characters wide. Call a function, named listSort(), that displays the list, in a tabular format (each column 15 characters wide), in ascending order (least to greatest) based on the number of games won.

Specifics:

-The array names are rank, teamName, gamesWon -listShow accepts three arrays and and an integer (string r[ ], string tn[ ], int gw[ ], int s) r represents rank, tn represenet teamName, gw represents gamesWon and s represents number of elements. -listSort accepts three arrays and and an integer (string r[ ], string tn[ ], int gw[ ], int s) r represents rank, tn represenet teamName, gw represents gamesWon and s represents number of elements. Use any sort algorithm. 

Download the data file from here: https://drive.google.com/file/d/1Ruh4dY_f8Nfuv5oFMD_jN-KzlqH-Z9Y5/view

mu iota tau psi omega Tigerettes Rhonos Righteous Ones Too Cool Reds 17 23 10 5 2

remove the path, C:\classdata\, from open statement

Take a look at the contents of the data file to determine how to read the data. Do NOT modify the data file.

Use the main function that has been provided. DO NOT make any changes to the code provided.

#include #include #include #include using namespace std;

void listShow(string[], string[], int[], int); void listSort(string[], string[], int[], int);

int main(){ const int listSize = 5; int gamesWon[listSize]; string teamName[listSize]; string rank[listSize]; ifstream fin; fin.open("C:\\classdata\\season2017.txt"); if(fin){ //Get rank for(int i = 0; i < listSize; i++){ getline(fin, rank[i]); }

//Get team name for(int i = 0; i < listSize; i++){ getline(fin, teamName[i]); } //Get games won for(int i = 0; i < listSize; i++){ fin >> gamesWon[i]; fin.ignore(1, ' '); } //fin.ignore(100, ' '); } else{ cout << "Error: file not found" << endl; }

cout << " Original List =============" << endl; listShow(rank, teamName, gamesWon, listSize); cout << " Sorted List (by games won) ===========================" << endl; listSort(rank, teamName, gamesWon, listSize);

return 0;

}

//Function Definitions Below

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!