Question: write in C++ (30) 2. Given the ADT Rational specification below design, implement, and test the member functions that perform arithmetic with fractions. Ensure that

write in C++
write in C++ (30) 2. Given the ADT Rational specification below design,

(30) 2. Given the ADT Rational specification below design, implement, and test the member functions that perform arithmetic with fractions. Ensure that the fractions are always stored in reduced form using the private member function reducel), e.g., if the fraction 21/30 is created either by a constructor or another member function, it should be stored as 7/10 (numerator/denominator).printRationalAsReal() should output a double value. Example output is given below (Rational bc6, 8); results in 3/4 being stored). 1/ catigoal.ch #ifndef. RATIONAL_H #define RATIONAL_H class Rational private: int numerator; Sell integer numerator int denominator; // integer denominator void reduce(); // reduces fraction to lowest form public: Rational(int = 0, int = 1); // stor Rational add(const Rational &); // addition function Rational subtract(const Rational &); // subtraction function Rational multiply(const Rational &); // multiplication function Rational divide(const Rational &); // division function void rcintRationall) const; // print rational format void rcintRationalAsBeall) const; // print rational as double }; // end Rational #endif 1* Example output: Testing class Rational 7/11 + 3/4 = 61/44 61/44 = 1.38636 7/11 - 3/4 = -5/44 -5/44 = -0.113636 7/11 * 3/4 - 21/44 21/44 = 0.477273 7/11 / 3/4 = 28/33 28/33 = 0.848485

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!