# Mini-Project 2 : Fun with Fractions

You goal in this project is to build a calculator (or perhaps many calculators) that (a) uses fractions as its basic numeric type and (b) includes registers.

## Required classes

• BigFraction.java. An extended version of the Fraction class you worked on in lab. You should make sure to reduce your fractions to the simplest form. You should also add other constructors as appropriate. You will also likely want to implement some other operations, such as subtraction and division.
• BFCalculator.java. The primary workhorse. This class should provide two (non-static) methods. (But it should not have a main.)
• evaluate(String exp) - evaluate an expression, ignoring priority
• store(char register) - store the last value computed in the named register.
• InteractiveCalculator.java. Here, you will provide a main method that will repeatedly read a line the user types, use a Calculator to compute the result, and print the result for the user.
• QuickCalculator.java. Here, you will provide a main method that will take the expressions from the command line and then print out the results.

What will the input strings look like?

• Expressions are sequence of values (either integers, fractions, or register names) separated by spaces and operators.
• Store commands will take the form STORE reg, where reg is a letter of the alphabet.
• We quit with QUIT. (If you know how, you can also stop at the end of input.)

For example, here’s a session with InteractiveCalculator.

$java InteractiveCalculator > 1/2 + 1/3 5/6 > STORE a > a + a 5/3 (or 1 2/3) > a / 2 + 1 17/12 (or 1 5/12) > 1 + a / 2 11/12 > QUIT Here’s an example session with QuickCalculator.$ java QuickCalculator "1/5 + 1/7" "STORE a" "a + 2"
1/5 + 1/7 = 12/35
a + 2 = 82/35

There is no precedence; you should evaluate operations from left to right. There may be an arbitrary number of values and operations on each line.

As this is a new assignment, the rubric may evolve slightly during grading.

### Redo or above

Submissions that fail to meet any of these requirements will get an I.

[ ] Includes the four specified .java files, correctly named.
[ ] Each class has an introductory Javadoc comment that indicates
the author and purpose.
[ ] Includes a README.md file.
[ ] The README.md file contains the appropriate information (authors,
purpose, acknowledgements if appropriate)
[ ] All files compile correctly.
[ ] QuickCalculator and InteractiveCalculator run.
[ ] BFCalculator includes the two required non-static methods,
evaluate and store.

### Meets expectations or above

Submissions that fail to meet any of these requirements but meet all previous requirements will receive an R.

and such.
[ ] Fractions always appear in simplest form.
[ ] Handles expressions with two fractions and one operation.
[ ] Handles expressions with one fraction, one register, and one operation.
[ ] All data are stored in class fields, so that we can have two
BFCalculator objects running simultaneously and they will not
interfere with each other.

### Exemplary / Exceeds expectations

Submissions that fail to meet any of these requirements but meet all previous requirements will receive an M.

[ ] All (or most) repeated code has been factored out into individual
methods.  It is *not* necessary that common code between
QuickCalculator and InteractiveCalculator be factored out into
a separate class.
[ ] All or most variable names are appropriate.
[ ] Handles expressions without fractional parts, such as 2 + 123.
[ ] Handles expressions with no operations, such as a, 11/2, or 5.
[ ] Handles negative numbers.
[ ] Handles expressions with multiple operations, such as 3/2 * 1/5 + 11/7.
[ ] Whole numbers appear as such and not as something like 11/1.
[ ] Provides an appropriate error message if the expression has the
wrong form (e.g., two numbers/registers in a row or two operations
in a row).

Acknowledgements: Parts of this assignment are inspired by assignments from past versions of CSC-207 (and perhaps even CSC-152).