No code sharing is allowed! Both offenders will have their score cancelled and will receive a much harder problem (or zero score for the test, at our discretion).
You need to do one of the following programs, by our choice. You will find the number of your assigned problem http://www.ccs.neu.edu/home/sbratus/com1101/problembyssn.html . Instead, you may decide to do the (hard) Problem D, which also brings extra credit. If you do so, you will be asked to explain your solution in a 10 minute interview with Sergey or Mani.
You need to read the descriptions of problems other than yours, because later problems refer to earlier ones.
You need to submit:
Implement the class Phonebook. The phonebook contains entries (name, phone number) and is searchable by name. More exactly, the class should allow the following operations.
Your class must be able to work with the following primitive driver program. Notice that by using the CoreTools functions RequestInt() and RequestString(..) from IOTools.* you can re-write this example to make it even shorter.
#include <iostream.h> #include <string> #include "phonebook.h" // the header file with your phonebook class int main(){ Phonebook phb; string cmd; // command string inp1, inp2; // input for a command while( true ){ cout << "Enter command (add, find, change, all): "; cin >> cmd; if( cmd == "add" ){ cout << "Name? "; getline( cin, inp1 ); // a name may contain spaces, hence getline cout << "Number? "; getline( cin, inp2 ); // phone number may contain spaces too phb.Add( inp1, inp2 ); } else if( cmd == "find" ){ cout << "Name? "; getline( cin, inp1 ); cout << "Result: " << phb.Find( inp1 ) << endl; // From this you can see that Find(..) returns a string. } else if( cmd == "change" ){ cout << "Name? "; getline( cin, inp1 ); cout << "New number? "; getline( cin, inp2 ); phb.Change( inp1, inp2 ); } else if( cmd == "all" ){ cout << "All entries:\n"; phb.PrintAll(); } else if( cmd == "quit" ) break; // leave the loop else cout << "Unrecognized command. Please try again.\n"; } cout << "Bye now\n"; return 0; }Naturally, such a phonebook is not much fun to use. Still, if instead of command line inteface someone writes a windowed interface for it (with dialog boxes, animations etc. etc.), it may become quite usable. The class Phonebook, though, would not need to change at all.
Implement a class Gradebook. The gradebook contains entries of the type (course, grade) and supports the following operations:
For this program you have to address the issues of duplicate entries (they are not permitted), and of lookups for a course which is not in the list. See Problem A for details.
For the driver code, refer to example for Problem A, with the commands being "add", "find", "all", "gpa" and "quit", and the methods of the class Gradebook called Add( string, string ), Find( string ), PrintAll(), GetGPA() respectively.
For extra credit, implement
The driver code is analogous to that of Problem A, with commands "add", "find", "all", "above" and "quit" and methods Add(string, int), Find(string), PrintAll() and PrintAbove( int ) respectively.
This problem may be chosen instead of the assigned problem. A quality solution is expected.
Implement a dictionary using a hash table. Fill the dictionary by reading in a file containing a list of words of the English language (provided). Then read a text and print out all words not in the dictionary (i.e. possible spelling errors). Your program may ignore case and punctuation. Further details are at http://www.ccs.neu.edu/home/sbratus/com1101/hash-dict.html