Rational fractions are of the form a/b, where a and b are integers and b≠0. 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 x c/d = (ac)/(bd)
(a/b) / (c/d) = ad/bc, where c/d ≠0
Fractions are compared as follows:
a/b op c/d if ad op bc, where op is any of the relational operators. For example, a/b < c/d if ad < bc.
Design a class, 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 operator and stream extraction operator for easy input and output.
Write a C++ program that uses the FractionType class to perform operations on fractions. Note that your answers do not need to be in lowest terms.
All 2 Replies
jonsca commented: That's too conservative of an estimate. First we've got to find yet another forum to repost his question on, wait for that answer, come back, answer the OP's question. That could take a day or two... :) +2
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.