Computer Networking: A Top-Down Approach (7th Edition)
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
Bartleby Related Questions Icon

Related questions

bartleby

Concept explainers

Question

BST - Binary Search Tree

- implement a BSTNode ADT with a data attribute and two pointer attributes, one for the left child and the other for the right child. Implement the usual getters/setters for these attributes

-implement a BST as a link-based ADT whose data will be Dollar objects - the data will be inserted based on the actual money value of your Dollar objects as a combination of the whole value and fractional value attributes.

- BST, implement the four traversal methods as well as methods for the usual search, insert, delete, print, count, isEmpty, empty operations and any other needed.

-

BST - Binary Search Tree

- implement a BSTNode ADT with a data attribute and two-pointer attributes, one for the left child and the other for the right child. Implement the usual getters/setters for these attributes

-implement a BST as a link-based ADT whose data will be Dollar objects - the data will be inserted based on the actual money value of your Dollar objects as a combination of the whole value and fractional value attributes.

- BST, implement the four traversal methods as well as methods for the usual search, insert, delete, print, count, isEmpty, empty operations and any other needed.

  • pgm will have at least 10 Dollar objects created from data specified in your main to seed the tree.
  • Read the data of your main to create your Dollar database using the BST.
  • Also, create an output file to write program output as specified in one or more instructions below.
  • Perform adequate data validation when reading data from the user into the tree - if any data item is invalid, ignore the data item and continue to next item but print a message to output (both screen and output file) to indicate which data items were ignored.
  • Provide interactivity for the user to add/search/delete nodes from the console after the data has been seeded into the application, including data validation.

USE THIS CLASS:

class Currency {

protected:

  int whole;

  int fraction;

  virtual string currName() = 0;

 

public:

  Currency() {

    whole = 0;

    fraction = 0;

  }

  Currency(double value) {

    if (value < 0)

      throw "Invalid value";

    whole = int(value);

    fraction = round(100 * (value - whole));

  }

  Currency(const Currency &obj) {

    whole = obj.whole;

    fraction = obj.fraction;

  }

 

  ~Currency() {}

  void setWhole(int setW) {

    if (setW >= 0)

      whole = setW;

  }

  void setFraction(int setFrac) {

    if (setFrac >= 0 && setFrac < 100)

      fraction = setFrac;

  }

  int getWhole() { return whole; }

  int getFraction() { return fraction; }

 

  void add(const Currency *obj) {

    whole += obj->whole;

    fraction += obj->fraction;

    if (fraction > 100) {

      whole++;

      fraction %= 100;

    }

  }

  void subtract(const Currency *obj) {

    if (!isGreater(*obj))

      throw "Invalid Subtraction";

    whole -= obj->whole;

    if (fraction < obj->fraction) {

      fraction = fraction + 100 - obj->fraction;

      whole--;

    } else {

      fraction -= obj->fraction;

    }

  }

 

  bool isEqual(const Currency &obj) {

    return obj.whole == whole && obj.fraction == fraction;

  }

  bool isGreater(const Currency &obj) {

    if (whole < obj.whole)

      return false;

    if (whole == obj.whole && fraction < obj.fraction)

      return false;

    return true;

  }

  void print() { cout << whole << "." << fraction << " " << currName() << " "; }

};

Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Computer Engineering
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-engineering and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Text book image
Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON
Text book image
Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science
Text book image
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning
Text book image
Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning
Text book image
Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education
Text book image
Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY