Question: Don't Modify Main Class only uses int value Keep fractions in reduced form (example: 1/2 not 2/4) represent 0 with 0/1 If a fraction is
Don't Modify Main Class only uses int value Keep fractions in reduced form (example: 1/2 not 2/4) represent 0 with 0/1 If a fraction is negative, then negative number should be in numerator. (Example: 1/2 and 1/2 -ok) If they are both negative then make it positive. (Example: 1/2 , 1/2 -not ok)
Phase One: Create a default constructor that creates the number (0/1)+(0/1)i Create a two variable constructor that creates (x/1)+(y/1)i Create a four variable constructor that creates (a/b)+(c/d)i add a private method that double checks both a/b and c/d are reduced No invalid numbers reduce fractions after entry check positive/negative of each fraction
Phase Two Create an operator that allows you to add two FractionalComplex together to create a third one. Create an operator that allows you to subtract two FractionalComplex togetehr to create a third one.
Adding and/or subtracting complex numbers requires adding real parts and imaginary parts together.
#include
using namespace std;
void intro(); void section1(); void section2();
int main() { void intro() {
void section1() { cout << "** Section 1" << endl; cout << "Basic creation and printing" << endl << endl; FractionalComplex a; FractionalComplex b(5, 10); FractionalComplex c(1,2,3,4); a.printme(); b.printme(); c.printme(); }
void section2() {
cout << endl << endl; cout << "** Section 2" << endl; cout << "Reductions " << endl << endl;
FractionalComplex a;
a = FractionalComplex(20, 6, 10, 8); a.printme(); a = FractionalComplex(-45, 105, 60, 54); a.printme(); a = FractionalComplex(-2, -4, -12, -8); a.printme(); a = FractionalComplex(1, -4, 2, -10); a.printme();
}
} }
Prints Out;
Section 1: Basic creation and printing
[(0/1)+(0/1)i]
[(5/1)+(10/1)i]
[(1/2)+(3/4)i]
Section 2: Reductions
[(10/3)+(5/4)i]
[(-3/7)+(10/9)i]
[(1/2)+(3/2)i]
[(-1/4)+(-1/5)i]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
