Question: Hello. I need to make this code run per these instructions but I'm not sure how to go about it. As a reference, I use

Hello. I need to make this code run per these instructions but I'm not sure how to go about it. As a reference, I use this website to check if code runs properly: https://www.onlinegdb.com/online_c++_compiler

Instructions:

Hello. I need to make this code run per these instructions but

Code:

//baseballscores.cpp #include #include

using namespace std;

void menu(); int loadFile(string file,string names[],int jNo[],int pos[],int scores[]); //function reads from file to parallel arrays string lowestScorer(string names[],int scores[],int size);//function gets name of lowest scrorer string highestScorer(string names[],int scores[],int size);//function gets name of highest scrorer void searchByName(string names[],int jNo[],int pos[],int scores[],int size);//function searches by name //int searchByPosition(string names[],int jNo[],int pos[],int scores[],int size);//function searches by position int totalPoints(int scores[],int size);//function gets total team points void sortByPlayerName(string names[],int jNo[],int pos[],int scores[],int size);//function sorts by player name along with jercy no, and score void displayToScreen(string names[],int jNo[],int pos[],int scores[],int size);//function displays all player details void writeToFile(string filename,string names[],int jNo[],int pos[],int scores[],int size);//function writes data to file

const int MAX=25; //declare maximum array size is 25

int main() { //declare parallel arrays string names[MAX]; int jNo[MAX],pos[MAX],scores[MAX]; string filename; int ch=0; cout>filename; //read file name int size=loadFile(filename,names,jNo,pos,scores); //calls the function for reading file while(ch!=8) //repeat until menu choice exit { menu(); cin>>ch;//input choice switch(ch) //check each choice { case 1: cout>filename; //input file to write writeToFile(filename,names,jNo,pos,scores,size);//writing data to file break; case 8: cout

//Function displays menu void menu() { cout

//function reads from file to parallel arrays int loadFile(string file,string names[],int jNo[],int pos[],int scores[]) { ifstream infile(file.c_str());//open file for reading int count=0;//initially count is 0 infile>>names[count]>>jNo[count]>>pos[count]>>scores[count];//read first record while(!infile.eof()) //read until end of file { count++;//increment count infile>>names[count]>>jNo[count]>>pos[count]>>scores[count];//read next records } infile.close(); //close the file return count;//finally return count }

//function gets name of lowest scrorer string lowestScorer(string names[],int scores[],int size) { int score=scores[0];//get startup 0th score string name; for(int i=0;iscores[i]) //compare name=names[i];//get name of lowest scorer } return name;//finally return name }

//function gets name of highest scrorer string highestScorer(string names[],int scores[],int size) { int score=scores[0];//get startup 0th score string name; for(int i=0;i

//function searches by name void searchByName(string names[],int jNo[],int pos[],int scores[],int size) { string name; bool flag=false; cout>name;//input name here for(int i=0;i

//function gets total team points int totalPoints(int scores[],int size) { int total=0; for(int i=0;i

//function sorts by player name along with jercy no, and score void sortByPlayerName(string names[],int jNo[],int pos[],int scores[],int size) { //using bubble sort for(int i=0;inames[j+1]) //compare names { //swapping names string t1=names[j]; names[j]=names[j+1]; names[j+1]=t1; //swapping jercy no int t2=jNo[j]; jNo[j]=jNo[j+1]; jNo[j+1]=t2; //swapping position int t3=pos[j]; pos[j]=pos[j+1]; pos[j+1]=t3; //swapping scores int t4=scores[j]; scores[j]=scores[j+1]; scores[j+1]=t4; } } }

//function writes data to file void writeToFile(string filename,string names[],int jNo[],int pos[],int scores[],int size) { ofstream outfile(filename.c_str());//open file for writing for(int i=0;i

//function displays all player details void displayToScreen(string names[],int jNo[],int pos[],int scores[],int size) { for(int i=0;i

//scores.txt

Rock 5 2 3 Kevin 2 10 2 John 8 1 4 Ram 7 8 3 Kittu 3 4 5 Krishna 9 8 3 Wills 12 7 2 Bush 8 1 2 Pebbel 4 6 4

Write a C++ program that reads a file with at least 9 player names, their jersey number, position and score on separate lines for a baseball team. Store the data into parallel arrays and then display the following choices in a menu lowest scorer highest scorer search by name or position total team points sort either by player names along with their jersey number and score or sort by jersey number, then name then score display to screen write to file Create a function for each menu item. Use arguments st for each function and pass in data. Do not use global variables. You can only use what you know at the time of the assignment based on material covered in Chapters 1 through 8. ANYTHING else is OUT OF SCOPE and will count off your grade 1/2 (.5) point each occurrence. Declare data types of variables (DO NOT USE AUTo) . You must deliver a .CPP file or .txt file . C++ keywords are lowercase User defined variables and functions should be in camelCase. Constant variables should be defined in ALL CAPS and can be separated by an underscore

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!