Welcome visitor ! You can login or create an account.

$15.00

$15.00

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.

The statement:

z=x+y;

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

- Fraction.zip [31.6KB]
- Fraction.cpp [2.1KB] [ preview ]Preview Content Inside File
#include using namespace std; class fractionType{ // form a/b public: double a; double b; fractionType(){ } fractionType(double u, double v){ a = u; b = v; }

- Fraction_screenshot.jpg [29.4KB]

- Fraction.cpp [2.1KB] [ preview ]