ZYBOOKS C++ 4.21 Soccer team roster: a use case of Vectors This program will sto
ID: 3889252 • Letter: Z
Question
ZYBOOKS C++
4.21 Soccer team roster: a use case of Vectors
This program will store roster and rating information for a soccer team. Coaches rate players during tryouts to ensure a balanced team.
(1) Prompt the user to input five pairs of numbers: A player's jersey number (0 - 99) and the player's rating (1 - 9). Store the jersey numbers in one int vector and the ratings in another int vector. Output these vectors (i.e., output the roster). (3 pts)
Ex:
(2) Implement a menu of options for a user to modify the roster. Each option is represented by a single character. The program initially outputs the menu, and outputs the menu after a user chooses an option. The program ends when the user chooses the option to Quit. For this step, the other options do nothing. (2 pts)
Ex:
(3) Implement the "Output roster" menu option. (1 pt)
Ex:
(4) Implement the "Add player" menu option. Prompt the user for a new player's jersey number and rating. Append the values to the two vectors. (1 pt)
Ex:
(5) Implement the "Delete player" menu option. Prompt the user for a player's jersey number. Remove the player from the roster (delete the jersey number and rating). (2 pts)
Ex:
(6) Implement the "Update player rating" menu option. Prompt the user for a player's jersey number. Prompt again for a new rating for the player, and then change that player's rating. (1 pt)
Ex:
(7) Implement the "Output players above a rating" menu option. Prompt the user for a rating. Print the jersey number and rating for all players with ratings above the entered value. (2 pts)
Ex:
Explanation / Answer
Note : Some what big program .I will update complete program. for sure...Thank You
________________
#include <iostream>
#include <vector>
using namespace std;
int main()
{
// Declaring vector
int jersNo, rate;
char choice;
vector<int> jersy;
vector<int> rating;
int jno, rt;
int i = 0;
// Declaring variable
int number;
for (int i = 0; i < 5; i++)
{
// Getting the number entered by the user.
cout << "Enter player " << i + 1 << "'s jersey number:" << endl;
jersNo = getJersyNo();
jersy.push_back(jersNo);
cout << "Enter player " << i + 1 << "'s rating:" << endl;
rate = getRating();
rating.push_back(rate);
}
cout << "MENU" << endl;
cout << "a - Add player" << endl;
cout << "d - Remove player" << endl;
cout << "u - Update player rating" << endl;
cout << "r - Output players above a rating" << endl;
cout << "o - Output roster" << endl;
cout << "q - Quit" << endl;
cout << "Enter Choice:";
cin >> choice;
switch (choice)
{
case 'a':
{
cout << "Enter a new player's jersey number:;
cin
>> jersNo;
jersy.push_back(jersNo);
cout << "Enter the player's rating:";
cin >> rating;
continue;
}
case 'd':
{
continue;
}
case 'u':
{
continue;
}
case 'r':
{
continue;
}
case 'o':
{
continue;
}
case 'q':
{
cout << ":: Program Exit ::" << endl;
break;
}
default:
{
cout << "** Invalid Choice **" << endl;
continue;
}
}
return 0;
}
int getJersyNo()
{
int jno;
while (true)
{
cin >> jersNo;
if (rate >= 0 && rate <= 99)
{
break;
}
else
{
cout << "Invalid.Must be between 0-99" << endl;
cout << "Enter :" << endl;
continue;
}
}
return jno;
}
int getRating()
{
while (true)
{
cin >> rate;
if (rate >= 1 && rate <= 9)
{
break;
}
else
{
cout << "Invalid.Must be between 1-9" << endl;
cout << "Enter :";
continue;
}
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.