#include "hashtable.h" #include "student.h" void main() { Hashtable *table; table = new Hashtable(); int flag = 1; while(flag) { int choice; cout << "\n Press 1 to add an element to the hashtable" << endl; cout << " Press 2 to delete an element from the hashtable" << endl; cout << " Press 3 to find an element in the hashtable" << endl; cout << " Press 4 to view contents of the table" << endl; cout << " Press 5 to exit the program" << endl; cout << "\n Please enter your choice: "; cin >> choice; cin.get(); if(choice == 5) flag = 0; else if(choice == 1) { char last_name[20]; char first_name[20]; char key[11]; double gpa; Student *st; bool result; cout << "\nEnter the key" << endl; cin >> key; cin.get (); cout << "\nEnter last name" << endl; cin >> last_name; cin.get(); cout << "\nEnter first name" << endl; cin >> first_name; cin.get (); cout << "\nEnter GPA" << endl; cin >> gpa; cin.get(); st = new Type(last_name, first_name, gpa, key); result = table->insert(st); if(result == true) cout << endl << "The record was successfully inserted" << endl; else cout << endl << "The record was not inserted" << endl; } else if(choice == 2) { char key[20]; bool result; cout << "\nEnter the key" << endl; cin >> key; cin.get (); result = table->remove(key); if(result == true) cout << endl << "The record was successfully deleted from the table" << endl; else cout << "The record was not found." << endl; } else if(choice == 3) { char key[20]; Student *s; cout << "\nEnter the key" << endl; cin >> key; cin.get (); s = table->find(key); if(s) cout << "Found record:" << *s; else cout << endl << "The record was not found" << endl; } else if(choice == 4) { table->view(); } else cout << "Invalid choice" << endl; }; }