need help with this assignment, I use C++. 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: 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: $57.12 $23.44 $87.43 $68.99 $111.22 $44.55 $77.77 $18.36 $543.21 $20.21 $345.67 $36.18 $48.48 $101.00 $11.00 $21.00 $51.00 $1.00 $251.00 $151.00 Thank you.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

I need help with this assignment, I use C++.

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

Thank you.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 6 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education