Question: This is my process, can you fix it for me? 0 Input: Output: Value: Under control of main function Under control of main function The




This is my process, can you fix it for me?


0 Input: Output: Value: Under control of main function Under control of main function The purpose of this assignment is to become familiar with the process of providing overloaded operators for a class. The Rational class from Labs 02, 03, and 05 will be modified to provide overloaded operators for performing arithmetic on Rational numbers an overloaded unary minus for negating a Rational number (previously implemented as the additive an overloaded assignment operator for assigning one Rational number to another (this is necessary since the private data includes an array overloaded operators for the equality operators and the relational operators, and overloaded input and output operators to facilitate the input and output of Rational numbers. A header file is shown in Figure 1, a sample main function for testing your implementation is shown in Figure 2, and a sample execution sequence is shown in Figure 3. To use the Makefile as distributed in class, add a target of lab07 to targets2srcfileswithlibrary. 1 #ifndef LAB07H - 2 #define LAB07-H #include using namespace std s class Rational 10 Ioverloaded input operator initializes Rational rat from input stream in 1 friend istreamk operator>> (istreank in, Rational& rat); 12 overloaded output operator prints Rational rat to output stream out 13 friend ostre& operator (const Rationalk rhs) const; bool operator (const Rational& rhs) const; // this-rhs // *thisrhs // *thi8 rhs // *thi8 rhs // *this rhs 4 private: int r[2] // rlo] represents numerator rpresents denominator 43int ged (int m, int n) const; // returns the greatest / common divisor of m /I and n // returns the least common // multiple of and n 4 int lcm(int m, int n) const; 50 #endif Figure 1. /usr/local/2336/include/lab07.h (Part 2 of 2) #include #include #include s using namespace std; 7 int main) Rational first(1, -2), second (-3, 0), result; cout > first >> second) cout " second) = " = second) /getlab.kah 07 * Checking to see if a folder exist8 for Lab 07. . .No *Creating a folder for Lab 07 Checking to see if Lab 07 has sample input and output files..Yes 6Copying input and output files for Lab 07 from folder /usr/local/2336/data/07 to folder/07 Checking to see if /uar/local/2336/arc/lab07main.c exists. . .Yea 9Copying file /uar/local/2336/src/lab07main.C to folder./07 10*Checking to see if /usr/local/2336/include/1ab07.h exists. . .Yes 11*Copying file /uar/local/2336/include/lab07.h to folder /07 12Copying file /usr/local/2336/arc/Makefile to folder ./07 * Adding a target of lab07 to targets2srcfileswith!ibrary 4Touching file /07/lab07.cpp 15*Edit file -/07/1ab07.cpp in Notepadt 6 newuseracsunix "/2336> cd 07 17 newuseracsunix "/2336/07> 1s 1s 01.dat i newuseracsunix "/2336/07> make lab07 20 g++ -g-Wall -std-c++11 -c lab07main.c-1/usr/local/2336/include -I 21 g+ -g-Wall -std-c++11- lab07.cpp -I/usr/local/2336/include -1 22gt - lab07 lab07main.o lab07.o -L/uar/local/2336/lib 23,-whole-archive -1lab07-Wl,-no-whole-archive -1m lbits 24 newuserdcsunix "/2336/07> cat 01.dat 25 -3 4 3 4 26 3-4-3-4 01.out Makefile lab07.cpp ab7.h lab07main.C 25 45 8 99 2 1 0 2 0 29 129 6579 1935 249 30 1331 1651 2301 1079 1 3 1260 6 198 32 43 1935 207 6579 5 7-25 -35 4 -83 1651 127-1079 s 1079 1651-1651 1079 Figure 3. Commands to Compile, Link, &Run Lab 07 (Part 1 of 3) newuseracsunix /2336/07> cat 01.dat /lab07 first1/-2 second-3/1 result0/1 first-3/4 -first 3/4 129/6579 1935/249 true 129/6579 1935/249 false 129/6579- 1935/249 false first 1331/1651 first-1331/1651 41 -3/4 3/4-9/16 1331/1651 +2301/1079402700/137033 s 1331/1651-2301/1079-181754/137033 43-3/43/4-false 44-3/4-3/4-true 45-3/4 3/4-true 4G-3/43/4-true 47-3/4> 3/4 false 4s3/4 3/4-false 49 first 3/-4 first3/4 so 3/-4 -3/-40/1 si 3/4-3/4--3/2 52 3/-4 * -3/-4 =-9/16 1331/1651 2301/1079235587/137033 1331/1651 2301/1079-110473/292227 1331/16512301/1079 false 1331/1651 2301/1079 true 100 1331/1651 8/99true 70 25/45 >= 8/99- true 71 first-1/1 -first=-1/1 72 43/1935 207/6579-304/32895 s 43/1935 207/6579 23/32895 119 43/1935/ 207/6579-731/1035 1 43/1935 207/6579false 1 43/1935- 207/6579true 2 43/1935 207/6579false 2 43/1935- 207/6579false 12 first5/7-first-5/7 7s 1/12/1-1/2 7e 1/12/1-false 71/12/1-true 129 5/7 -25/-35-25/49 * 5/7 / -25/-35 1/1 1/1 2/1= false s1 1/1 2/1-false 82 first 129/6579 -first-1/51 s3 129/6579 1935/24932978/4233 s4 129/6579 1935/249-32812/4233 s 129/6579 * 1935/249 215/1411 s 129/6579 1935/249 83/32895 7 129/6579 1935/249 false s 129/6579- 1935/249true 12 5/7!-25/-35false 133 5/7 -25/-35= false 16 5/7-25/-35true 7 first-83/1651 -first 83/1651 3s -83/1651 127/-1079-23018/137033 39-83/1651-127/-1079 9240/137033 140 -83/1651 127/-1079 1/169 141 -83/1651 127/-1079 6889/16129 Figure 3. Commands to Compile, Link, &Run Lab 07 (Part 2 of 3) Page 4 CS 2336Data Structures and Algorithms Lab 7 Due Date: See Blackboard 142-83/1651. 127/-1079= false 143 -83/1651 - 127/-1079-true 144 -83/1651 127/-1079 false 145 -83/1651 127/-1079 false 146-83/1651> 127/-1079 = true 147 -83/1651 127/-1079 true 148 first-1079/1651 -first=-83/127 | 157 1079/1651 > -1651/1079 = true 149 1079/1651 -1651/1079-9240/10541581079/1651 -1651/1079- true 150 1079/1651 -1651/1079-23018/10541 151 1079/1651 -1651/1079-1/1 52 1079/1651-1651/1079--6889/16129 153 1079/165122-1651/1079 = false 154 1079/1651Iz-1651/1079= true 155 1079/1651 cat 01.dat ./lab07 > my.out 160 nevuserdcaunix /2336/07> diff 01.out my.out 161 nevuseracunix /2336/07> Figure 3. Commands to Compile, Link, & Run Lab 07 (Part 3 of 3) istream& operator>>(istream& in, Rational& rat) int num, denom; if (in >>num > denom) rat.setNumerator(num); rat.setDenominator(denom); else rat.setNumerator(0); rat.setDenominator(1); return in; // overloaded output operator prints Rational rat to output stream out ostream& operatorsetNumerator(rhs.getNumerator()) this->setDenominator(rhs.getDenominator()) return *this; Rational Rational::operator+(const Rational& addend) const// returns *this int lcm - this->lcm(this->getDenominator(), addend.getDenominator()); Rational sum;//declare a local Rational object //populate the data elements of sum sum.setDenominator(1cm); sum.setNumerator (lcm * this->getNumerator) / this->getDenominator() +1cm*addend.getNumerator) addend.getDenominator(); sum.reduce) return sum;//return the local object Rational Rational::operator-() const // returns - (*this) return Rational(this->getNumerator) * -1, this->getDenominator()) Rational Rational::operator-(const Rational& subtrahend) const// returns *this - subtrahend return *this + -subtrahend; //return this->operator+(subtrahend.operator-)); Rational Rational::operator*(const Rational& multiplicand) const// returns *this multiplicand Rational Rational::operator-() const // returns - (*this) return Rational(this->getNumerator)-1, this->getDenominator)); Rational Rational::operator-(const Rational& subtrahend) const// returns *this - subtrahend return *this + -subtrahend; //return this->operator+(subtrahend.operator-)); Rational Rational::operator* (const Rational&multiplicand) const// returns *this *multiplicand Rational multiple; multiple.setNumerator( this-> getNumerator) multiplicand.getNumerator(); multiple.setDenominator(this-> getDenominator() multiplicand.getDenominator)) multiple.reduce) return multiple; Rational Rational::operator/ (const Rational& divisor) const// returns *this / divisor Rational division; division.setNumerator(this->getNumerator) * divisor.getDenominator)); division.setDenominator(this->getDenominator() *divisor.getNumerator)) division.reduce(); return division bool operator-(const Rational& rhs) const *this rhs //return this->subtract (other).getNumerator()0; return (*this - rhs).getNumerator) 0 bool operator!-(const Rational& rhs) const *this !- rhs return !(*thisrhs); bool operator (const Rational& rhs) const II*this> rhs return (*this > rhs); bool operator (const Rational& rhs) const II*this >- rhs return (*this >rhs)