Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

To practice the use of vectors and search algorithms: Specifications: This program will allow the user to see a list of five teams, or search

To practice the use of vectors and search algorithms:

Specifications:

This program will allow the user to see a list of five teams, or search for a team using an ID

1.TeamS Structure Definition

Define the 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.

2.In the main function, declare an empty vector named TeamV of type TeamS. Add the following team data to the TeamV vector using the vector push-back function. One team per vector element :

Team 100: "Donald", "Goofy", "Pluto"

Team 101: "Luke", "Leia", "Han"

Team 102: "Natasha", "Carol", "Wanda"

Team 103: "Harry", "Ron", "Hermione"

Team 104: "May", "Peter", "Mary Jane"

3.displayTeams function

From main, call the displayTeams function (see the prototype below) to show that your vector has been populated with the team information. The function simply displays the contents of the vector: team id and corresponding team members for each team.

void displayTeams (const vector &TeamV);

4.Define a menu function for displaying the interface menu

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. Make sure only menu choices 1 4 are allowed.

Define a function with the following prototype to display the menu:

void menu();

If the user selects menu option 1, call the displayTeams function to display the list of teams.

No credit will be given for this step if the display menu source code is written in the main function. A function call to the menu function should be used for displaying the menu. You are allowed to have the input statement for the menu choice in the main function.

5.Searching for a team Linear Search

If the user selects menu option 2, ask for the Team ID the user wants to search for and call a function with the listed prototype. The function should perform a linear search on the teamV vector for the matching id. If a matching id is found the function should display the team information for the matching id. If not found display Team ID not found".

void linSearchTeams(const vector &TeamV, int id );

Make sure that this function performs a linear search and displays only the vector entry for the matching id if found.

6.Searching for a team Binary Search

If the user selects menu option 3, ask for the Team ID the user wants to search for and call a function with the listed prototype. The function should perform a binary search on the teamV vector for the matching id. If a matching id is found the function should display the team information for the matching id. If not found display Team ID not found.

void binSearchTeams(const vector &TeamV, int id );

Make sure that this function performs a binary search and displays only the vector entry for the matching id if found.

7.Ending the program

If the user selects menu option 4, exit the program.

Display the following message: Exiting program

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

Database Design Application Development And Administration

Authors: Mannino Michael

5th Edition

0983332401, 978-0983332404

More Books

Students also viewed these Databases questions

Question

=+j Describe the various support services delivered by IHR.

Answered: 1 week ago