numerator and long denominator.
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.
Remember to change the namespace of your program to UML.Assignment3.
It’s OK to have your result be an improper fraction (where the numerator ends up larger than the denominator).
Are you looking for a similar paper or any other quality academic essay? Then look no further. Our research paper writing service is what you require. Our team of experienced writers is on standby to deliver to you an original paper as per your specified instructions with zero plagiarism guaranteed. This is the perfect way you can prepare your own unique academic paper and score the grades you deserve.
Use the order calculator below and get started! Contact our live support team for any assistance or inquiry.[order_calculator]