5.19 Ch 5 Program: Soccer team roster (Vectors) (C++)
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:
Enter player 1's jersey number: 84 Enter player 1's rating: 7 Enter player 2's jersey number: 23 Enter player 2's rating: 4 Enter player 3's jersey number: 4 Enter player 3's rating: 5 Enter player 4's jersey number: 30 Enter player 4's rating: 2 Enter player 5's jersey number: 66 Enter player 5's rating: 9 ROSTER Player 1 -- Jersey number: 84, Rating: 7 Player 2 -- Jersey number: 23, Rating: 4 ...
(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:
MENU a - Add player d - Remove player u - Update player rating r - Output players above a rating o - Output roster q - Quit Choose an option:
(3) Implement the "Output roster" menu option. (1 pt)
Ex:
ROSTER Player 1 -- Jersey number: 84, Rating: 7 Player 2 -- Jersey number: 23, Rating: 4 ...
(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:
Enter a new player's jersey number: 49 Enter the player's rating: 8
(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:
Enter a jersey number: 4
(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:
Enter a jersey number: 23 Enter a new rating for player: 6
(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:
Enter a rating: 5 ABOVE 5 Player 1 -- Jersey number: 84, Rating: 7 ...
#include <iostream>
// FIXME include vector library
using namespace std;
int main() {
/* Type your code here. */
return 0;
}
`Hey,
Note: Brother in case of any queries, just comment in box I would be very happy to assist all your queries
#include <iostream>
#include <vector>
using namespace std;
struct Player
{
int jerseyNum;
int rating;
};
int searchPlayer(vector<Player> vec, int jerseyNum);
int main()
{
// Declaring vector
vector<Player> vec(0);
struct Player p;
// Declaring variables
char choice;
int jerseyNum, rating;
for(int i=0;i<5;i++)
{
cout<<"Enter player"<<i+1<<"'s jersey number:"<<endl;
cin>>p.jerseyNum;
cout<<"Enter player"<<i+1<<"'s rating:"<<endl;
cin>>p.rating;
vec.push_back(p);
}
/* This while loop continues to execute
* until the user enters a valid input choice
*/
while (true)
{
// displaying the menu
cout << "\nMENU" << endl;
cout << "a - Add Player" << endl;
cout << "d - Relete 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;
// getting the choice entered by the user
cout << "Enter Choice :";
cin >> choice;
// Based on the user choice the corresponding case will executed
switch (choice)
{
case 'a':
{
cout << "Enter a new Player's jersey number :";
cin >> jerseyNum;
cout << "Enter the player's rating :";
cin >> rating;
Player p;
p.jerseyNum = jerseyNum;
p.rating = rating;
vec.push_back(p);
}
continue;
case 'd':
{
cout << "Enter a Player's jersey number :";
cin >> jerseyNum;
int index = searchPlayer(vec, jerseyNum);
if (index == -1)
{
cout << "** Player not found **" << endl;
}
else
{
vec.erase(vec.begin() + index);
}
continue;
}
case 'u':
{
cout << "Enter a Player's jersey number :";
cin >> jerseyNum;
int index = searchPlayer(vec, jerseyNum);
if (index == -1)
{
cout << "** Player not found **" << endl;
}
else
{
cout << "Enter the player's rating :" << endl;
cin >> rating;
vec[index].rating = rating;
}
continue;
}
case 'r':
{
cout << "Enter a rating :";
cin >> rating;
cout << "ABOVE " << rating << endl;
for (int i = 0; i < vec.size(); i++)
{
if (vec[i].rating > rating)
{
cout << "Player" << (i + 1) << " -- Jersey Number:" << vec[i].jerseyNum
<< ", Rating:" << vec[i].rating << endl;
}
}
continue;
}
case 'o':
{
cout << "ROSTER" << endl;
for (int i = 0; i < vec.size(); i++)
{
cout << "Player" << (i + 1) << " -- Jersey Number:" << vec[i].jerseyNum
<< ", Rating:" << vec[i].rating << endl;
}
continue;
}
case 'q':
{
cout << "** PROGRAM EXIT**" << endl;
break;
}
default:
{
cout << "Invalid Choice" << endl;
continue;
}
}
break;
}
}
// This method will check whether the jersey number is available in the array list or not
int searchPlayer(vector<Player> vec, int jerseyNum)
{
for (int i = 0; i < vec.size(); i++)
{
if (vec[i].jerseyNum == jerseyNum)
return i;
}
return -1;
}
Kindly revert for any queries
Thanks.
5.19 Ch 5 Program: Soccer team roster (Vectors) (C++) This program will store roster and rating...
Java 7.17 Clone of LAB*: Program: Soccer team roster 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, but this is NOT enforced by the program nor tested) and the player's rating (1-9, not enforced like jersey numbers). Store the jersey numbers in one int array and the ratings in another int...
5.22 LAB*: Program: Soccer team roster steam This program will store roster and rating information for a soccer team Coaches rate players during tryouts to ensure (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 in one int array and the ratings in another int array Output these arrays (e. output the roster) (3 pts) numbers EX Enter player 1 jersey number: Enter player l's rating: Enter player...
5.19 Lab 11b: Soccer team roster Instructor note: NOTE Unlike our other assignments, this one has only two programs: People's Weights and this one. To earn 30 points, you must do both assignments. Allow ample time to complete them Passing arrays to methods Review Chapter 6.8 Array Parameters if you wish to use methods in your program (a good idea). Since we pass a reference to the array's location in memory, changes made to the array within the method will...
In C Program This program will store the roster and rating information for a soccer team. There will be 3 pieces of information about each player: Name: string, 1-100 characters (nickname or first name only, NO SPACES) Jersey Number: integer, 1-99 (these must be unique) Rating: double, 0.0-100.0 You must create a struct called "playData" to hold all the information defined above for a single player. You must use an array of your structs to to store this information. You...
This program will store a roster of most popular videos with kittens. The roster can include at most 10 kittens.You will implement structures to handle kitten information. You will also use functions to manipulate the structure. (1) Create a structure kitten. The structure should contain the following attributes: name; string color; string score; integer Important! The name of the structure and each of its field must match exactly for the program to work and be graded correctly. (2) Create a...
(C++) Write a program that declares a struct to store the data of a football player (player’s name, player’s position, number of touchdowns, number of catches, number of passing yards, number of receiving yards, and the number of rushing yards). Declare an array of 10 components to store the data of 10 football players. Your program must contain a function to input data and a function to output data. Add functions to search the array to find the index of...
C++ Language Overview: Design an APP for a basketball team with a unique name. There should be at least 10 players. The member variables required include team member’s names, jersey number, position played, and at least 3 stats. Positions are small forward, power forward, center, shooting guard and point guard. 1. A.) Design a class with member variables and appropriate member functions Data should be stored in a read/write file consisting of team member’s names, jersey number, position played, and...
Chapter 8 Python Case study Baseball Team Manager For this case study, you’ll use the programming skills that you learn in Murach’s Python Programming to develop a program that helps a person manage a baseball team. This program stores the data for each player on the team, and it also lets the manager set a starting lineup for each game. After you read chapter 2, you can develop a simple program that calculates the batting average for a player. Then,...
#PLEASE WRITE THE CODE IN JAVA! THANK YOU IN ADVANCE! Write a program that manages a list of up to 10 players and their high scores in the computer's memory. Use two arrays to manage the list. One array should store the players' names, and the other array should store the players' high scores. Use the index of the arrays to correlate the names with the scores. Your program should support the following features: a. Add a new player and...
c++ A menu-driven program gives the user the option to find statistics about different baseball players. The program reads from a file and stores the data for ten baseball players, including player’s team, name of player, number of homeruns, batting average, and runs batted in. (You can make up your data, or get it online, for example: http://espn.go.com/mlb/statistics ) Write a program that declares a struct to store the data for a player. Declare an array of 10 components to...