Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Problem You are to create a simple database using a hash table. The database wil

ID: 3639633 • Letter: P

Question

Problem
You are to create a simple database using a hash table. The database will keep track of a
small club consisting of members who pay monthly dues. The dues are collected each
month and are based on the members’ participation in volunteer activity. The more a
member participates in monthly activities, the less the dues for that month. Use the
database to produce a yearly report for each member, listing their monthly dues.

Input
A file read at the command in the argv[ ] variable. This file will contain a list of member names and their monthly volunteer time in hours.

Output
A table listing the member, the months (1 year, 12 months), and the dues for each month. This table is to be displayed on the standard output (see below)

Class requirements
Your hash table class must be based on a static array which is dimensioned by a non-type
parameter. In addition, the template for the class should list two other paramters—a type
for the table and a type for a pointer to a hash function. Furthermore, the class must
contain at least the following members.
1. At least one constructor that takes the parameter representing a pointer to a hash
function.
2. Insert function to insert something into the hash table.
3. A display function shows the hash table in a formatted tabular form on the standard
output.
4. A nested exception class that throws an error when the capacity of the table is
exceeded. This class should be derived from std::exeption and should be named
table_overflow. The exception should print a string “Overflow error”, when it is
caught. Use a reference to the base class as the catch argument.

Program requirements
1. Present the user with a greeting.
2. Read the file with the members and the hours in argv[1].
3. Build the hash table and compute the statistics.
4. Display the hash table.
5. Don’t forget to enable exception handling in the program with try/catch/throw

Notes
1. To facilitate this project, create a struct that stores the member name, hours worked
for each month, and monthly dues for each month. You may add other data members
if you like.
2. Your hash function should compute a table slot based on a persons name as follows.
Table slot = key mod table_size, where key is computed as the sum of the ascii values
of the person’s name. If there is a “collision” (table slot is already occupied), use the
following function to resolve it.
Table slot = (key + i) mod table_size, where i = 0, 1, 2, … , table_size-1

3. The format of the input file will be as follows.
Amy 7 4 9 8 9 5 5 3 7 10 9 10
Bob 3 9 10 5 8 9 9 10 4 7 9 10
// Other entries
The space-delimited numbers represent hours worked each month beginning with
January and ending with December.

// Output
Amy
Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
5.50 4.00 7.50 2.00 5.50 10.00 8.50 7.50 6.00 6.50 8.00 5.50
Bob
// Same as above

4. Compute the dues (hours worked * rate), where the rates are as follows (in dollars)
r>0 && r<2 10.17
r>=2 && r<4 8.15
r>=4 && r<6 6.13
r>=6 && r<8 4.11
r>=8 2.09

Explanation / Answer

#ifndef H_HashDef #define H_HashDef #include #include #include #include #include using namespace std; class HtType { public: HtType(); //default constructor //initializes Size, the number //of current elements in the table void ReadData(); int hashFunction(const char *key, int keyLenght); void LinearProbing(); void PrintData(); private: int size; string word[131]; const char *word2; int len; int hIndex; int HTSIZE; string hashTable[131]; int IndexStatusList[131]; }; HtType::HtType() { size = 0; HTSIZE = 131; for(int b = 0; b word[size]; size++; } } } int HtType::hashFunction(const char *key, int keyLenght) { int sum = 0; for(int j =0; j
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote