I need help with this assignment, I use C++. Can you also please show the console for the program? Thank you. Write a program to do the following: Use the same input seed data you used for Lab 4 (your BST homework) as seed input data into a hash table. Declare a hash table of size 29 elements. To hash your currency objects into the hash table, use the pseudorandom hash scheme - (m*w + n*f) % size - where size = 29, m = 2, n = 3, w = whole value, f = fractional value. For collision resolution, use quadratic probing in the same direction always. Remember to circle around to the start of the array if needed. Your main will first load the data file into the hash table and print the number of data items loaded, load factor and number of collisions. Then it will ask the user in a loop to enter a Dollar to search for. If the Dollar object is found in the hash table, it will print the index where found, otherwise it will print 'Invalid Data'. Then it will ask the user if they want to check again or end the program. To submit, upload your code files and screenshot of the console only. For documentation, only name blocks and existing documentation in your Dollar class are needed. Dollar Code: class Dollar : public Currency { private: string nameOfCurrency; public: Dollar(){ nameOfCurrency="dollar"; } Dollar( double value): Currency(value){ nameOfCurrency="dollar"; } //Prints function. void print() { cout << get_whole() << '.' << get_fraction() << " dollars" << endl; } }; Currency Code:

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

I need help with this assignment, I use C++. Can you also please show the console for the program? Thank you.

Write a program to do the following:

  1. Use the same input seed data you used for Lab 4 (your BST homework) as seed input data into a hash table.
  2. Declare a hash table of size 29 elements.
  3. To hash your currency objects into the hash table, use the pseudorandom hash scheme - (m*w + n*f) % size - where size = 29, m = 2, n = 3, w = whole value, f = fractional value.
  4. For collision resolution, use quadratic probing in the same direction always. Remember to circle around to the start of the array if needed.
  5. Your main will first load the data file into the hash table and print the number of data items loaded, load factor and number of collisions.
  6. Then it will ask the user in a loop to enter a Dollar to search for. If the Dollar object is found in the hash table, it will print the index where found, otherwise it will print 'Invalid Data'. Then it will ask the user if they want to check again or end the program.
  7. To submit, upload your code files and screenshot of the console only.
  8. For documentation, only name blocks and existing documentation in your Dollar class are needed.

Dollar Code:

class Dollar : public Currency {
private:

string nameOfCurrency;
public:

Dollar(){
nameOfCurrency="dollar";
}

Dollar( double value): Currency(value){
nameOfCurrency="dollar";
}
//Prints function.
void print() {
cout << get_whole() << '.' << get_fraction() << " dollars" << endl;
}
};

Currency Code:

class Currency {
private:
int whole;
int fraction;

public:
int get_whole() {
return whole;
}

int get_fraction() {
return fraction;
}

void set_whole(int input_whole) {
whole = input_whole;
}

void set_fraction(int input_fractional) {
fraction = input_fractional;
}

Currency() {
whole = 0;
fraction = 0;
}

Currency(double input) {
whole = int(input) ;
fraction = (int)round(fabs(input - trunc(input)) * 1e2);
}

Currency(const Currency & p1) {

whole = p1.whole;
fraction = p1.fraction;
}

~Currency() {

}
//Add method
void add(double input) {
whole = whole + int(input);
fraction = fraction + (int)round(fabs(input - trunc(input)) * 1e2);;
}
//Subtract method
void subtract(double input) {
int whole_input = int(input);
int fraction_input = (int)round(fabs(input - trunc(input)) * 1e2);
if (whole-whole_input < 0 || fraction-fraction_input < 0) {
cout << "Invalid subtraction" << endl;
}
else {
whole = whole - whole_input;
fraction = fraction - fraction_input;
}
}

bool isEqual(Currency c1, Currency c2) {
if (c1.whole == c2.whole){
if (c1.fraction == c2.fraction)
return true;
}
return false;
}

bool isGreater(Currency c1, Currency c2) {
if (c1.whole > c2.whole)
return true;
if (c1.fraction == c2.fraction) {

if (c1.fraction > c2.fraction)
return true;
else
return false;
}
return false;
}

void print() {
cout << get_whole() << '.' << get_fraction() << endl;
}
};

Data:

  1. $57.12
  2. $23.44
  3. $87.43
  4. $68.99
  5. $111.22
  6. $44.55
  7. $77.77
  8. $18.36
  9. $543.21
  10. $20.21
  11. $345.67
  12. $36.18
  13. $48.48
  14. $101.00
  15. $11.00
  16. $21.00
  17. $51.00
  18. $1.00
  19. $251.00
  20. $151.00
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 7 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY