Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a class template that will create a binary tree that can hold values of any data type Then, design an EmployeeInfo class that holds

Write a class template that will create a binary tree that can hold values of any data type Then, design an EmployeeInfo class that holds the following employee info:

Employee ID Number: an integer

Employee Name: a string

Implement a binary tree whose nodes hold an instance of the EmployeeInfo class. The nodes are to be sorted on the Employee ID Number. The program shall display the employees in numeric order, and allow the user to enter an ID number, and search the tree for the number. If the number is found, the program will display the employee name, and if the number is not found, the program will display Employee not found. Either way the program will prompt for another employee number or Q to quit using a loop.

Test using this info:

1021 John Williams

1057 Bill Witherspoon

2487 Jennifer Twain

3769 Sophia Lancaster

1017 Debbie Reece

1275 George McMullen

1899 Ashley Smith

4218 Josh Plemmons

Code should include two headers, employeeInfo.h AND binarytree.h

Example of main

int main() { int num = 0; BinaryTree tree; // create a BinaryTree object EmployeeInfo wkr1(1021, "John Williams"); // put data into object tree.insertNode(wkr1); // put object into tree EmployeeInfo wkr2(1057, "Bill Witherspoon"); tree.insertNode(wkr2); EmployeeInfo wkr3(2487, "Jennifer Twain"); tree.insertNode(wkr3); EmployeeInfo wkr4(3769, "Sophia Lancaster"); tree.insertNode(wkr4); EmployeeInfo wkr5(1017, "Debbie Reece"); tree.insertNode(wkr5); EmployeeInfo wkr6(1275, "George McMullen"); tree.insertNode(wkr6); EmployeeInfo wkr7(1899, "Ashley Smith"); tree.insertNode(wkr7); EmployeeInfo wkr8(4218, "Josh Plemmons"); tree.insertNode(wkr8); cout << "Here is the workforce: "; // Display the workforce. tree.displayInOrder(); cout << " Enter an employee number: "; // Get an ID number to search for. cin >> num; EmployeeInfo *ptr = tree.searchNode(num); // Search for the employee in the tree. if (ptr) { cout << "Employee was found: " << *ptr; } else { cout << "That employee was not found. "; } return 0; }

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

Microsoft Visual Basic 2005 For Windows Mobile Web Office And Database Applications Comprehensive

Authors: Gary B. Shelly, Thomas J. Cashman, Corinne Hoisington

1st Edition

0619254823, 978-0619254827

More Books

Students also viewed these Databases questions

Question

Define and measure service productivity.

Answered: 1 week ago