Representation and manipulation of rational numbers in C++

Requirements

Task is to define a class to represent and manipulate rational numbers (fractions), so that by simply changing the type of n1 and n2 to Rational the program will compute fractional

arithmetic expressions such as these:


1/2 + 1/3 // answer: 5/6
1/3 - 1/4 // answer: 1/12
2/3 * 4/5 // answer: 8/15
3/7 / 2/3 // answer: 9/14

Download the file fractions_0.zip, which contains the calculator code and a skeleton version of the Rational class. The class defines (but doesn't fully implement) appropriate constructors to initialise instances of Rational, extract and insert operators for input and output of Rational values, and of course arithmetic operators to compute the results.


Get Project Solution Now

Comments