#### Description of this paper

##### Define a class called Fraction that houses a long numerator and long denominator.

Description

solution

Question

Define a class called Fraction that houses a long numerator and long denominator. The constructor should accept two parameters representing the numerator and denominator respectively. If the caller passes a denominator of 0, display an error message using Console.WriteLine, wait for the user to hit ENTER, and exit the program using Environment.Exit.;Your Fraction class needs to implement the following methods;? Add. Calculates the sum of two fractions and returns the result as a Fraction.;? Subtract. Calculates the difference of two fractions and returns the result as a Fraction.\;? Multiply. Calculates the product of two fractions and returns the result as a Fraction.;? DivideBy. Calculates the quotient of the two fractions and returns the result as a Fraction.;? Reduced. Calculates the reduced version of the fraction, e.g., 5 / 10 reduced is 1 / 2 and 6 / 20 reduced is 3 / 10.;Implement each of these methods as an instance method of the Fraction class. Here are some sample uses;Fraction f = new Fraction(1, 2), // 1/2;Fraction g = new Fraction(2, 3), // 2/3;Fraction sum = f.Add(g), // f + g;Fraction product = f.Multiply(g), // f * g;Fraction diff = f.Subtract(g), // f - g;Fraction quot = f.DivideBy(g), // f / g;Fraction reduced = sum.Reduced(), // sum reduced;This is the external interface to your class. You may have internal (private) members that help with calculating the least-common-multiple to calculate your common denominator when you need to add and subtract, etc.;Notes;? Remember to change the namespace of your program to UML.Assignment3.;Helpful Hints;? It?s OK to have your result be an improper fraction (where the numerator ends up larger than the denominator).

Paper#65640 | Written in 18-Jul-2015

Price : \$27