Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help making a simple hash function for a c++ programming assignment. In the assignment you will take a list of employee data and

I need help making a simple hash function for a c++ programming assignment. In the assignment you will take a list of employee data and use it to generate an employee ID by implementing a hash function. I can't rename any existing functions or add any additional function or member variables. The program will read in a text file containing a list of employees. The program will iterate those employees and generate an ID for each. The program will output the ID along with the rest of the employee data to the output file. The ID should be limited to no more than 6 digits and will be numeric. The only changes will be to the employee.cpp file.

employee.h:

#ifndef __EMPLOYEE_H__ #define __EMPLOYEE_H__

#include #include

struct Employee { std::string FirstName; std::string LastName; std::string Phone; std::string Email; std::string Address;

std::size_t hash() const; };

inline std::istream& operator>>(std::istream& is, Employee& e) { is >> e.LastName >> e.FirstName >> e.Phone >> e.Email; std::getline(is, e.Address); return is; }

inline std::ostream& operator<<(std::ostream& os, const Employee& e) { os << e.LastName << "\t" << e.FirstName << "\t" << e.Phone << "\t" << e.Email << "\t" << e.Address; }

#endif // __EMPLOYEE_H__

main.cpp:

#include #include #include #include #include #include #include

#include "employee.h"

int main(int argc, char** argv) { if (argc != 3) { std::cout << "Usage: assignment08 [input file] [output file]" << std::endl; return 0; }

std::ifstream fin(argv[1]); std::ofstream fout(argv[2]);

std::deque employees;

std::copy(std::istream_iterator(fin), std::istream_iterator(), std::back_inserter(employees)); std::for_each(employees.begin(), employees.end(), [&](const Employee& e) { fout << e.hash() << "\t" << e << std::endl; });

return 0; }

employee.cpp:

#include

#include "employee.h"

std::size_t Employee::hash() const { //to do }

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_2

Step: 3

blur-text-image_3

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

Database Systems Introduction To Databases And Data Warehouses

Authors: Nenad Jukic, Susan Vrbsky, Svetlozar Nestorov

1st Edition

1943153191, 978-1943153190

More Books

Students also viewed these Databases questions

Question

5. If individuals are not autonomous then what are they?

Answered: 1 week ago

Question

1 What are the three key facets of HRP?

Answered: 1 week ago