public string Division(Fractional fract) { int num, denum; num = this.numerator * fract.denumerator; denum = this.denumerator * fract.numerator; Fractional fractional = new Fractional(num, denum); fractional.Simplification(); return(fractional.Print()); }
public static void Task3() { Fractional fract = new Fractional(); Fractional fract1 = new Fractional(); Console.WriteLine(fract.Print() + "+" + fract1.Print() + " = " + fract.Summ(fract1)); Console.WriteLine(fract.Print() + "-" + fract1.Print() + " = " + fract.Subtraction(fract1)); Console.WriteLine(fract.Print() + "*" + fract1.Print() + " = " + fract.Multiplication(fract1)); Console.WriteLine(fract.Print() + "/" + fract1.Print() + " = " + fract.Division(fract1)); Fractional fract3 = new Fractional(5, 400); Fractional fract4 = new Fractional(5, 400); fract4.Simplification(); Console.WriteLine("Упрощение " + fract3.Print() + " = " + fract4.Print()); }
public string Subtraction(Fractional fract) { int num, denum; if (this.denumerator == fract.denumerator) { num = this.numerator - fract.numerator; denum = this.denumerator; } else { num = this.numerator * fract.denumerator - fract.numerator * this.denumerator; denum = this.denumerator * fract.denumerator; } Fractional fractional = new Fractional(num, denum); fractional.Simplification(); return(fractional.Print()); }