Question
C++ Help with this code Code: #include #include #include using namespace std; //Function that prints menu void menu() { cout //Function that adds player to
C++ Help with this code
Code:
#include
#include
using namespace std;
//Function that prints menu void menu() { cout
//Function that adds player to roster void addPlayer(vector
//Reading jersey numbers cout > temp;
//Storing in vector jerseyNumbers.push_back(temp);
//Reading rating cout > temp;
//Storing in vector ratings.push_back(temp);
cout
//Function that prints ROSTER to console void outputRoster(vector
cout
//Looping over each element in the vector and printing to console for(i=0; i cout //Function that deletes an existing player from roster void deletePlayer(vector //Reading jersey numbers cout > jerseyNumber; //Looping over each element in the vector and searching for given jersey number for(i=0; i //If player not found if(pos == -1) { cout //Deleting ratings from vector ratings.erase(ratings.begin() + pos); cout //Function that updates an existing player from roster void updatePlayer(vector //Reading jersey numbers cout > jerseyNumber; //Looping over each element in the vector and searching for given jersey number for(i=0; i //If player not found if(pos == -1) { cout > rating; //Updating ratings vector ratings[pos] = rating; cout //Function that displays the details of player whose rating is above the given rating void aboveRating(vector //Reading rating cout > rating; cout //Looping over each element in the vector and printing to console for(i=0; i cout //Main function int main() { //Vectors to hold jersey numbers vector //Vectors to hold ratings vector char option; //Storing five player details for(i=0; i> temp; //Storing in vector jerseyNumbers.push_back(temp); //Reading rating cout > temp; cout //Storing in vector ratings.push_back(temp); } //Loop till user wants to quit while(1) { //Printing menu menu(); //Reading option from user cout > option; //Calling appropriate function switch(option) { case 'a': addPlayer(jerseyNumbers, ratings); break; case 'd': deletePlayer(jerseyNumbers, ratings); break; case 'u': updatePlayer(jerseyNumbers, ratings); break; case 'r': aboveRating(jerseyNumbers, ratings); break; case 'o': outputRoster(jerseyNumbers, ratings); break; case 'q': exit(0); default: cout cout
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started