Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

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).

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M91418611
  • Price:- $60

Priced at Now at $60, Verified Solution

Have any Question?


Related Questions in Computer Engineering

Discussion 2 initial post due friday by midnight estdefine

Discussion 2: Initial post due Friday by midnight EST Define and briefly discuss the following brainstorming techniques, the delphi technique, brainstorming, or nominal group technique. For your discussion, you are requi ...

Question 1two variables have a negative non-linear

Question 1 Two variables have a negative non-linear correlation. Does the dependent variable increase or decrease as the independent variable increases? A)Dependent variable would remain the same B)Dependent variable inc ...

We live in kapurkua a small island in the mediterranean

We live in Kapurkua, a small island in the mediterranean between Greece and Spain (no, it doesn't really exist so don't look it up in the map). In the island we produce and consume canoes, latreks (a garment that is comf ...

Question suppose that you discover that ram addresses

Question : Suppose that you discover that RAM addresses 000C0000 to 000C7FFF are reserved for a PC's video adapter in a 32-bit computer. How many bytes of memory is this?

A decision maker has ordered every commodity in walmart

A decision maker has ordered every commodity in Walmart alphabetically according to the commodity's name. Every time when he needs to choose from several commodities, he always choose the second one according to his orde ...

A bit-comparator is a combinational circuit with 2 inputs a

A Bit-Comparator is a combinational circuit with 2 inputs, A and B, and 3 outputs. L, E and G. Output L is 1 if A Output E is 1 if A = B, otherwise E is 0. Output G is 1 if A > B, otherwise G is 0. Show how the 2x4 decod ...

Question cybersecurity policy design issues1describe

Question: Cybersecurity Policy Design Issues 1. Describe cybersecurity roles and responsibilities to protect security for the corporate business mission (for example, the Insider threat, Access Controls, Biometric Authen ...

Williamnbspis interested in knowingnbspwhether or not

William is interested in knowing  whether or not athletics from his team have lower satisfaction with their team on a survey than the known population average survey score of 19  and the known population survey standard ...

The data reflects student enrollment at a college in

The data reflects student enrollment at a college in Southern California. Traditional math pathwayAccelerated math pathwayRow totalsFemale12441161360Male1054541108Column totals22981702468 We want to determine if the prob ...

Roberto is the network administrator for an international

Roberto is the network administrator for an international law firm with offices and customers in North America, South America, Africa, and the Middle East. The lawyers frequently contact each other via e-mail, use the In ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As