Rational fractions are of the form a / b, where a and b are integers and b not equal to 0. By "fractions" I mean rational fractions. Suppose a / b and c / d are fractions. Arithmetic operations on fractions are defined by the following rules:
a/b + c/d = (ad + bc) / bd
a/b - c/d = (ad - bc) / bd
a/b * c/d = ac / bd
(a/b) / (c/d) = ad / bc , in which c/d does not equal 0.
Fractions are compared as follows: a/b op c/d if ad op bc, 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 use 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:
cout<< x+y<< endl;
Should output the value of x + y in fraction form.
Should store the sum of x and y in z in fraction form. The answer should store the sum of x and y in z in fraction form. The answer does not need to be in lowest terms.
A++ solution for this question
Solution contain C++ program and ScreenShot.
Using DevC++ IDE to run program.
If you want run on Visual studio, you can edit some lines in source code (i can help you do it).