Here is a class of rational numbers i discussed briefly in class.

A description of a stack based calculator using rational numbers can be seen in this assignment (given to a difference class). Click Here.

SO...your task is to revise your calculator from hw4 such that it will work with either the Rational Number class (the code for that is given in the first link), or in a double class, which will work just like standard doubles.

  1. Write a double class. It should have one member variable, a double. Write a constructor and accessors to get at that double. NOTE: You may not call your class "double" because that is a reserved keyword. Some logical variant on the name will be fine.
  2. Get the rational class working. Test it.
  3. Find the similarities in the classes. Write a super class which has these shared traits. Adapt your double and rational class to inherit.
  4. Figure out how to adapt nodes and/or stacks to use this new structure. TAKE ADVANTAGE OF THE FACT THAT THERE IS A SUPERCLASS.
  5. You may allow the user to select whether to use a rational number calculator or a double calculator.
  6. From there, make the calculator work.