Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Working in C++ This program will allow the user to see a list of teams, add a team to the list, or search for a

Working in C++

image text in transcribed

image text in transcribed

This program will allow the user to see a list of teams, add a team to the list, or search for a team using an ID 1. Structure Definition First define struct Teams with an integer field to hold an ID, and an array of strings with three elements to hold the names of the team members. In the main function, declare an empty vector of TeamV and also the following arrays: conat int ID [NUM TEAMS -1123, 321, 456, 789) const string MEMBERS (NUM TEAMS] [UM MEMBERS "Sally", "Joe", "John", "Chris", "Kevin","Jams") "Tom","Kim", "Emily") "Ji11", "Jacob", "Jim") 2. Creating the vector Call a function with the following prototype and pass in the empty vector and the arrays: void Initialize (vector &Teamv, const int id The function should place into the vector the elements of the arrays. const string mUM MEMBERS], int arraySize) For example, the first element of the vector will have team id: 123 and members: Sarah, Joe, and John. The second element of the vector will have team id: 321 and members: Chris, Kevin, and James, and so on 3. The print function Back in main, call a function with the following prototype to show that your vector has been populated with the team information: void printList (const vector &Team) The function simply prints out the content of the vector. Make sure that the output is neatly formatted. 4. The menu Function Next, place a loop in your main function such that in each iteration the user sees a menu and has the chance to enter a choice. Call a function with the following prototype to display the menu: void menu ) If the users selects option 1, call the printList function to display the list. 5. Adding to a vector If the user selects option 2, call a function with the following protoype which will allow the user to enter the information for a team which will be added to your team vector void add (vector &TeamV) 6. Searching a Vector If the user selects option 3, ask for the ID the user wants to search for and call a function with the following protoype which will perform a search on your vector and return the index of the element with the matching ID or -1 if no match is found: int search (const vector & TeamV, int id): Make sure that this function performs a linear search. 7. Displaying a selected vector entry In the search function, printout the information of the team with the matching ID In main, use the return value of the function to determine if an error message is to be displayed if no matching ID is found. If so, display "no such team" to the user 8. Ending the program If the user selects option 4, stop the program. Display the following message Lab 2 written by XXXXXX has ended. Where XXXXXX is vour First and Last name

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

PostgreSQL Up And Running A Practical Guide To The Advanced Open Source Database

Authors: Regina Obe, Leo Hsu

3rd Edition

1491963417, 978-1491963418

More Books

Students also viewed these Databases questions

Question

What advice would you provide to Jennifer?

Answered: 1 week ago

Question

What are the issues of concern for each of the affected parties?

Answered: 1 week ago