Question: Using the ElementDatabase.cpp file given below, create a database of chemical elements (elements from the periodic table). The program interface should match the example below.

Using the ElementDatabase.cpp file given below, create a database of chemical elements (elements from the periodic table). The program interface should match the example below. File -

 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
#include  using namespace std; struct Element { int atomicNumber; string symbol; string name; Element *left; Element *right; }; class ElementDatabase{ private: Element* root; void addElement(Element *&e, int atomicNumber, string symbol, string name){ } void printElements(Element *e){ } // Returns the address of the element if a match is found // Return NULL if no match is found Element* findElementBySymbol(Element *e, string symbol){ return NULL; } // Returns the address of the element if a match is found // Return NULL if no match is found Element* findElementByName(Element *e, string name){ return NULL; } void deleteElement(Element *&e, int atomicNumber){ } public: ElementDatabase(){ root = NULL; } void addElement(int atomicNumber, string symbol, string name){ addElement(root, atomicNumber, symbol, name); } void printElements(){ printElements(root); } // Returns the address of the element if a match is found // Return NULL if no match is found Element* findElementBySymbol(string symbol){ return findElementBySymbol(root, symbol); } // Returns the address of the element if a match is found // Return NULL if no match is found Element* findElementByName(string name){ return findElementByName(root,name); } void deleteElement(int atomicNumber){ deleteElement(root,atomicNumber); } }; int main(){ // Complete the functions above // Add more functions if necessary // Create the menu as shown in the example of program execution // The program should only exit when the user chooses "Exit program" } 

Example -

----------------------------- 1. Add an element 2. View elements 3. Search elements by chemical symbol 4. Search elements by element name 5. Delete an element 6. Exit program Enter your choice: 1 ** Add an element ** Enter atomic number: 3 Enter chemical symbol: Li Enter element name: Lithium Element added successfully. ----------------------------- 1. Add an element 2. View elements 3. Search elements by chemical symbol 4. Search elements by element name 5. Delete an element 6. Exit program Enter your choice: 1 ** Add an element ** Enter atomic number: 36 Enter chemical symbol: Kr Enter element name: Krypton Element added successfully. ----------------------------- 1. Add an element 2. View elements 3. Search elements by chemical symbol 4. Search elements by element name 5. Delete an element 6. Exit program Enter your choice: 1 ** Add an element ** Enter atomic number: 2 Enter chemical symbol: He Enter element name: Helium Element added successfully. ----------------------------- 1. Add an element 2. View elements 3. Search elements by chemical symbol 4. Search elements by element name 5. Delete an element 6. Exit program Enter your choice: 2 ** View Elements ** 2, He, Helium 3, Li, Lithium 36, Kr, Krypton ----------------------------- 1. Add an element 2. View elements 3. Search elements by chemical symbol 4. Search elements by element name 5. Delete an element 6. Exit program Enter your choice: 3 ** Search Elements by Chemical Symbol ** Enter chemical symbol: Li Search result: 3, Li, Lithium ----------------------------- 1. Add an element 2. View elements 3. Search elements by chemical symbol 4. Search elements by element name 5. Delete an element 6. Exit program Enter your choice: 3 ** Search Elements by Chemical Symbol ** Enter chemical symbol: Co Search result: No element was found. ----------------------------- 1. Add an element 2. View elements 3. Search elements by chemical symbol 4. Search elements by element name 5. Delete an element 6. Exit program Enter your choice: 4 ** Search Elements by Element Name ** Enter chemical symbol: lithium Search result: 3, Li, Lithium ----------------------------- 1. Add an element 2. View elements 3. Search elements by chemical symbol 4. Search elements by element name 5. Delete an element 6. Exit program Enter your choice: 4 ** Search Elements by Element Name ** Enter element name: HELIUM Search result: 2, He, Helium ----------------------------- 1. Add an element 2. View elements 3. Search elements by chemical symbol 4. Search elements by element name 5. Delete an element 6. Exit program Enter your choice: 4 ** Search Elements by Element Name ** Enter element name: Oxygen Search result: No element was found. ----------------------------- 1. Add an element 2. View elements 3. Search elements by chemical symbol 4. Search elements by element name 5. Delete an element 6. Exit program Enter your choice: 5 ** Delete an element ** Enter atmoic number: 2 Do you want to delete: 2, He, Helium Enter y or n:y Element deleted successfully. ----------------------------- 1. Add an element 2. View elements 3. Search elements by chemical symbol 4. Search elements by element name 5. Delete an element 6. Exit program Enter your choice: 5 ** Delete an element ** Enter atmoic number: 5 No element was found. ----------------------------- 1. Add an element 2. View elements 3. Search elements by chemical symbol 4. Search elements by element name 5. Delete an element 6. Exit program Enter your choice: 2 ** View Elements ** 3, Li, Lithium 36, Kr, Krypton ----------------------------- 1. Add an element 2. View elements 3. Search elements by chemical symbol 4. Search elements by element name 5. Delete an element 6. Exit program Enter your choice: 6 Program has exited..

Submit a single .cpp file.

The database must be implemented using a Binary Search Tree data structure. Use the atomic number as the key (to decide which element will get left or right in the tree).

*Search by name should work for uppercase and lowercase letters.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!