(Solved) : Write Rational Number Calculator Rational Number Number Form B B Integers B 0 Also Convent Q35589140
write a rational number calculator. A rational number is anumber of the form a/b, where a and b are integers and b != 0.Also, by convention, a/b is always shown in reduced form, i.e., thegreatest common divisor of a and b is 1, and if a == 0 then b == 1.You will implement a Rational class allowing use of rationalnumbers as an abstract data type via a library. You will also writea client calculator program to drive the rational number class andallow testing the operations on rational expressions. It will readthe rational numbers from a file, in the form ( a / b ) ( c / d )where the parentheses are required, a, b, c and d are integers(possibly signed) and is one of +, -, * or /. Your output will beto another file, with lines of output in the form ( a / b ) ( c / d) = ( e / f ) Loop over the input file until end-of-file. Take thefile names for the input and output files from the command linearguments. In both input and output formats, the spaces betweentokens are required. Your class will be called Rational, and mustbe defined in a header file (a file named rational.h) andimplemented in a separate library source file (named rational.cpp),both in the current working directory. Your client code (another.cpp file) will #include the header you wrote using double quotes,not angle brackets: #include “rational.h” instead of like this:#include and will be linked with the class object file. You willcreate a project containing the 2 source files. Your class mustprovide public methods to add, subtract, multiply, and dividerational numbers. These must have the general form RationalRational::add( Rational augend ) This adds “this” (*this or self)rational number (the addend) to the argument augend (remember, sum= addend + augend) producing another Rational for the sum, andreturns the sum Rational object. The other functions; subtract(),multiply(), and divide(), will also take a rational number andtreat it as the right hand operand of their particular operation,using “this” as the left hand side operand. None of theseoperatorlike methods may change their operands (either theparameter or “self” AT ALL. These operator-like methods may take areference instead of a value parameter. You may return a referencealso, but you have to be careful not to return a reference to atemporary local Rational object (which will be destroyed when themethod returns). Your private data elements in the Rational classmust be two longs called num and denom for the numerator anddenominator. You may not have any other data elements in the classAT ALL. You MAY NOT add other parameters to the add(), multiply(),etc., methods. Your data members must be private. You must alsoprovide at least these other methods: • default and normalconstructors, • observers (i.e., to print a rational number to anoutput file handle, in the form ( a / b ) with parenthesisrequired, with the leading sign on a optional unless negative) •manipulators (i.e., to read a rational number from the keyboard ora file handle in the form ( a / b ), or to take supplied values andset them into the rational number) • other private “helper”functions, for example, to convert the rational number to its”normal” form as described above.