/fraction.java

A simple implementation of fractions in Java.

Primary LanguageJavaBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

Fraction class (Java implementation)

A simple implementation of fractions, used to learn OOP in Java.

The Fraction class supports:

  • addition, subtraction, multiplication and division
  • simplification (2/4 -> 1/2)
  • mixed numbers (eg. 5/2 == 2 1/2)

The Fraction class currently does not support:

  • comparisons
  • unit testing

A similar project was written in C++.

Usage: compile and run with your favorite Java execution environment.

Licensed under the 3-clause BSD license.