Beispiel #1
0
 public Fraction division(Fraction f) {
   Fraction div = new Fraction();
   int num = numerator * f.getDenominator();
   div.setNumerator(num);
   int den = denominator * f.getNumerator();
   div.setDenominator(den);
   return div;
 }
Beispiel #2
0
 public Fraction subtraction(Fraction f) {
   Fraction sub = new Fraction();
   int num = numerator * f.getDenominator() - f.getNumerator() * denominator;
   sub.setNumerator(num);
   int den = denominator * f.getDenominator();
   sub.setDenominator(den);
   return sub;
 }
Beispiel #3
0
 public Fraction multiplication(Fraction f) {
   Fraction mul = new Fraction();
   int num = numerator * f.getNumerator();
   mul.setNumerator(num);
   int den = denominator * f.getDenominator();
   mul.setDenominator(den);
   return mul;
 }
Beispiel #4
0
 // <MATH Section>
 public Fraction addition(Fraction f) {
   Fraction add = new Fraction();
   int num = numerator * f.getDenominator() + f.getNumerator() * denominator;
   add.setNumerator(num);
   int den = denominator * f.getDenominator();
   add.setDenominator(den);
   return add;
 }