Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 #include

using namespace std;

//Function that prints menu void menu() { cout

//Function that adds player to roster void addPlayer(vector& jerseyNumbers, vector& ratings) { int temp;

//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 jerseyNumbers, vector ratings) { int i;

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& jerseyNumbers, vector& ratings) { int jerseyNumber; int pos = -1, i;

//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& jerseyNumbers, vector& ratings) { int jerseyNumber, rating; int pos = -1,i;

//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 jerseyNumbers, vector ratings) { int rating, i;

//Reading rating cout > rating;

cout

//Looping over each element in the vector and printing to console for(i=0; i rating) cout

cout

//Main function int main() { //Vectors to hold jersey numbers vector jerseyNumbers;

//Vectors to hold ratings vector ratings; int i, temp;

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

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

1. Compare output Enter player 4's jersey number: Enter player 4's rating: 84 7 23 4 er player 5' jersey number Enter player 5's jer Enter player 5's rating: 30 2 66 9 ROSTER Flayer 1Jersey number: 84, Rating: 7 Player 21- Jersey number: 23, Rating; 4 Player 3Jersey number , Rating: 5 Player 4Jersey number: 30, Rating: 2 Flayer 5 Jersey number: 66, Rating: 9 Enter player 1's jersey number: Enter player 1's rating: Enter player 2's jersey number: Enter player 2's rating: Enter player 3' jersey number: Enter player 3's rating: 2 Compare output Enter player 4's jersey number: Enter player 4's rating: 0r1 Enter player 5's jersey number: Enter player 5's rating: 21 5 Input 478 Your output starts witlh 83 2 MENU -Add player d Delete player Enter player 1's jersey nmber Enter player 1's rating: Update player rating Enter player 2's jersey number: Enter player 2's rating: r- Output players above a rating - output roster Quit Enter player 3's jersey number Enter player 3's rating: Choose ar option: Your output starts with Enter player 1's jersey number: Enter player 1's rating: Enter player 4's jersey number Enter player 4's rating: Enter player 2's jersey number: Enter player 2's rating: Enter player 's jersey number: Enter player 5's rating: Expected output stats with Enter player 3's jersey number: Enter player 3's rating: MENU

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

Data Access Patterns Database Interactions In Object Oriented Applications

Authors: Clifton Nock

1st Edition

0321555627, 978-0321555625

More Books

Students also viewed these Databases questions

Question

Explain the concept of shear force and bending moment in beams.

Answered: 1 week ago

Question

What is the purpose of the Salary Structure Table?

Answered: 1 week ago

Question

What is the scope and use of a Job Family Table?

Answered: 1 week ago