question archive Rational fractions are of the form a/b, in which a and b are integers and bx0

Rational fractions are of the form a/b, in which a and b are integers and bx0

Subject:Computer SciencePrice: Bought3

Rational fractions are of the form a/b, in which a and b are integers and bx0. In this exercise, by "fractions" we mean rational fractions. Suppose a/b and c/d are fractions. Arithmetic operations on fractions are defined by the following rules: alb + old = (ad + be)/bd alb - old = (ad - bc)/bd a/b X old = aclbd (a/b)/(c/d) = ad/bc; in which c/d # 0. Fractions are compared as follows: a/b op cid if ad op be, in which op is any of the relational operations. For example, a/b < c/d if ad < bc. Design a class-say, fractionType-that performs the arithmetic and relational operations on fractions. Overload the arithmetic and relational operators so that the appropriate symbols can be used to perform the operation. Also, overload the stream insertion and stream extraction operators for easy input and output. Write a C+ + program that, using the class fractionType, performs operations on fractions. Among other things, test the following: Suppose x, y, and z are objects of type fractionType. If the input is 2/3, the statement cin > > x; should store 2/3 in x. The statement cout << x + y << endl; should output the value of x + y in fraction form. The statement Z = X + YI should store the sum of x and y in z in fraction form. Your answer need not be in the lowest terms. For out Additional Requirements Use a template so the class works with any kind of number (Le, int, float, double) Twoazini> num1(5, 61 (awinnType-float> num1(5.1, 6 21 Tip: get your class working with integer values first for numerator and denominator and convert to a template after it is working with jus. When converting to a template you may need to move all of your implementation into the .h header file. (Ctrl) -

pur-new-sol

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE