Output is all wrong.
When first starting program it should look like this:
Please enter two non-zero integers:
then I type in these two integers 14 6 and hit enter.
The next line says:
Please enter Rational number:
Then I type in this Rational number (22, 4) and hit enter.
The output should be these lines:
Test1 equals (7, 3)
Test2 equals (14, 1)
Test3 equals (11, 2)
Test1 * Test2 equals (98, 3)
Test1 / Test3 equals (14, 33)
Test2 + Test3 equals (39, 2)
Test3 - Test1 equals (19, 6)
Test1 is less than Test2
Test2 is greater than Test3
Test3 is greater than or equal to Test1
Another test case?
Note that program has to ignor parentheses ( ) and the comma , .
All of the operators required in the problem should be provided for the Rational class as overloaded, Friend functions. In general, you should be able to execute code such as following:
// Display the three values to test cout
cout << "\nTest1 equals " << test1;
cout << "\nTest2 equals " << test2;
cout << "\nTest3 equals " << test3;
// Test our operators
cout << "\nTest1 * Test2 equals " << test1*test2;
cout << "\nTest1 / Test3 equals " << test1/test3;
cout << "\nTest2 + Test3 equals " << test2+test3;
cout << "\nTest3 - Test1 equals " << test3-test1;
if (test1 == test2)
cout << "\nTest1 is equal to Test2";
if (test1 < test2)
cout << "\nTest1 is less than Test2";
The above code has to be in. And a Friend function has to be used.