PLS DO FAST I WILL GIVE LIKE FOR SURE. SOLUTION MUST BE IN TYPED FORM I need help in C++ I need to modify the following code to work with complex numbers op: Complex × Complex → Complex op: Complex × double → Complex op: double × Complex → Complex the output should be like : (1 + 2i) + (1 + 3i) = (2 + 5i) (1 + 2i) - (1 + 3i) = (0 + -1i) (1 + 2i) * (1 + 3i) = (-5 + 5i) (1 + 2i) / (1 + 3i) = (0.7 + -0.1i) (1 + 2i) + 5 = (6 + 2i) (1 + 2i) - 5 = (-4 + 2i) (1 + 2i) * 5 = (5 + 10i) (1 + 2i) / 5 = (0.2 + 0.4i) 5 + (1 + 2i) = (6 + 2i) 5 - (1 + 2i) = (4 + -2i) 5 * (1 + 2i) = (5 + 10i) 5 / (1 + 2i) = (1.0 + -2.0i) *** need imaginary number i *** /* rational.h */ #ifndef RATIONAL_H #define RATIONAL_H #include using std::ostream; struct rational { rational(int = 0, int = 1); rational operator+(const rational &) const; rational operator-(const rational &) const; rational operator*(const rational &) const; rational operator/(const rational &) const; rational operator+(int) const; rational operator-(int) const; rational operator*(int) const; rational operator/(int) const; friend rational operator+(int, const rational &); friend rational operator-(int, const rational &); friend rational operator*(int, const rational &); friend rational operator/(int, const rational &); friend ostream &operator< #include "rational.h" rational::rational(int num, int den) : num(num), den(den) {} rational rational::operator+(const rational &o) const { return rational(num * o.den + o.num * den, den * o.den); } rational rational::operator+(int n) const { return rational(num + n * den, den); } rational rational::operator-(const rational &o) const { return rational(num * o.den - o.num * den, den * o.den); } rational rational::operator-(int n) const { return rational(num - n * den, den); } rational rational::operator*(const rational &o) const { return rational(num * o.num, den * o.den); } rational rational::operator*(int n) const { return rational(num * n, den); } rational rational::operator/(const rational &o) const { return rational(num * o.den, den * o.num); } rational rational::operator/(int n) const { return rational(num, den * n); } rational operator+(int n, const rational &o) { return o + n; } rational operator-(int n, const rational &o) { return rational(n) - o; } rational operator*(int n, const rational &o) { return o * n; } rational operator/(int n, const rational &o) { return rational(n) / o; } ostream &operator< #include "rational.h" using std::cout; using std::endl; int main(void) { rational a(1, 2); rational b(1, 3); int i = 5; cout << a << " + " << b << " = " << a + b << endl; cout << a << " - " << b << " = " << a - b << endl; cout << a << " * " << b << " = " << a * b << endl; cout << a << " / " << b << " = " << a / b << endl; cout << a << " + " << i << " = " << a + i << endl; cout << a << " - " << i << " = " << a - i << endl; cout << a << " * " << i << " = " << a * i << endl; cout << a << " / " << i << " = " << a / i << endl; cout << i << " + " << a << " = " << i + a << endl; cout << i << " - " << a << " = " << i - a << endl; cout << i << " * " << a << " = " << i * a << endl; cout << i << " / " << a << " = " << i / a << endl; return 0; }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
PLS DO FAST I WILL GIVE LIKE FOR SURE. SOLUTION MUST BE IN TYPED FORM I need help in C++ I need to modify the following code to work with complex numbers op: Complex × Complex → Complex op: Complex × double → Complex op: double × Complex → Complex the output should be like : (1 + 2i) + (1 + 3i) = (2 + 5i) (1 + 2i) - (1 + 3i) = (0 + -1i) (1 + 2i) * (1 + 3i) = (-5 + 5i) (1 + 2i) / (1 + 3i) = (0.7 + -0.1i) (1 + 2i) + 5 = (6 + 2i) (1 + 2i) - 5 = (-4 + 2i) (1 + 2i) * 5 = (5 + 10i) (1 + 2i) / 5 = (0.2 + 0.4i) 5 + (1 + 2i) = (6 + 2i) 5 - (1 + 2i) = (4 + -2i) 5 * (1 + 2i) = (5 + 10i) 5 / (1 + 2i) = (1.0 + -2.0i) *** need imaginary number i *** /* rational.h */ #ifndef RATIONAL_H #define RATIONAL_H #include using std::ostream; struct rational { rational(int = 0, int = 1); rational operator+(const rational &) const; rational operator-(const rational &) const; rational operator*(const rational &) const; rational operator/(const rational &) const; rational operator+(int) const; rational operator-(int) const; rational operator*(int) const; rational operator/(int) const; friend rational operator+(int, const rational &); friend rational operator-(int, const rational &); friend rational operator*(int, const rational &); friend rational operator/(int, const rational &); friend ostream &operator< #include "rational.h" rational::rational(int num, int den) : num(num), den(den) {} rational rational::operator+(const rational &o) const { return rational(num * o.den + o.num * den, den * o.den); } rational rational::operator+(int n) const { return rational(num + n * den, den); } rational rational::operator-(const rational &o) const { return rational(num * o.den - o.num * den, den * o.den); } rational rational::operator-(int n) const { return rational(num - n * den, den); } rational rational::operator*(const rational &o) const { return rational(num * o.num, den * o.den); } rational rational::operator*(int n) const { return rational(num * n, den); } rational rational::operator/(const rational &o) const { return rational(num * o.den, den * o.num); } rational rational::operator/(int n) const { return rational(num, den * n); } rational operator+(int n, const rational &o) { return o + n; } rational operator-(int n, const rational &o) { return rational(n) - o; } rational operator*(int n, const rational &o) { return o * n; } rational operator/(int n, const rational &o) { return rational(n) / o; } ostream &operator< #include "rational.h" using std::cout; using std::endl; int main(void) { rational a(1, 2); rational b(1, 3); int i = 5; cout << a << " + " << b << " = " << a + b << endl; cout << a << " - " << b << " = " << a - b << endl; cout << a << " * " << b << " = " << a * b << endl; cout << a << " / " << b << " = " << a / b << endl; cout << a << " + " << i << " = " << a + i << endl; cout << a << " - " << i << " = " << a - i << endl; cout << a << " * " << i << " = " << a * i << endl; cout << a << " / " << i << " = " << a / i << endl; cout << i << " + " << a << " = " << i + a << endl; cout << i << " - " << a << " = " << i - a << endl; cout << i << " * " << a << " = " << i * a << endl; cout << i << " / " << a << " = " << i / a << endl; return 0; }
Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Fibonacci algorithm
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education