Page 1 of 1

c++

Posted: Thu Jul 14, 2022 2:16 pm
by answerhappygod
c++
C 1
C 1 (76.12 KiB) Viewed 36 times
C 2
C 2 (84.73 KiB) Viewed 36 times
C 3
C 3 (69.27 KiB) Viewed 36 times
2. Continuous of question 1. Implement operator overloading. Operator Overloading a) Implement two unary operator overload functions (−,+,!). b) Implement four arithmetic operator overload functions (+,−,∗,/). c) Implement six relational operator overload functions (==,!=,>,>=,<,<=). d) Implement the insertion operator overload function (≪<). e) Implement the extraction operator overload function (≫). f) Implement the subscript operator overload function ([]). Make sure that each function is optimally overloaded for its purpose. (pick between member, non-member, friend as appropriate) Notes Add Rational Numbers Given a/b+c/d : Step 1: Find the LCM of b and d. Step 2: Create a new Rational Number: ((a∗(LCM/b)+(c∗(LCM/d))/LCM. Step 3: Reduce the new Rational Number from step 2. Step 4: Return the new Rational Number. Subtract Rational Numbers Given a/b−c/d : Step 1: Find the LCM of b and d. Step 2: Create a new Rational Number: ((a∗(LCM/b)−(c∗(LCM/d))/LCM. Due date: Jul 17, 11:59 PM Step 3: Reduce the new Rational Number from step 2. Step 4: Return the new Rational Number.
Multiply Rational Numbers Given a/b * c/d : Step 1: Create a new Rational Number: (a∗c)/(b∗d). Step 2: Return the new Rational Number. Divide Rational Numbers Given a/b * c/d: Step 1: Create a new Rational Number: (a∗c)/(b∗d). Step 2: Return the new Rational Number. Compare Rational Numbers: greater than Determine if a/b>c/d : Step 1: Find the LCM of b and d. Step 2: If (a∗(LCM/b)>(c∗(LCM/d) return true, otherwise false. Compare Rational Numbers: less than Determine if a/b<c/d : Step 1: Find the LCM of b and d. Step 2: If (a∗(LCM/b)<(c∗(LCM/d) return true, otherwise false. Use following main function to test your program. (have to use this main function)