Write a program to do rational number arithmetic, representing each rational number as a class that has instance variables for the numerator and the denominator. The program should read and display all rational numbers in the format a/b, or simply a if the denominator is 1. I have enclosed what I have however it doesn't work right. In c++
Input ---------------------------- Output
3/8 + 1/6--------------------------13/24
3/8 - 1/6---------------------------5/24
3/8 * 1/6--------------------------1/16
3/8 / 1/6---------------------------9/4
3/8 I -------------------------------8/3 ---------------invert a/b
8/3 M ----------------------------- 2 + 2/3-----------Write a/b as a mixed fraction
6/8 R ------------------------------3/4 ---------------reduce a/b to lowest terms
6/8 G ------------------------------2------------------Greatest common divisor of num ..
1/6 L 3/8-------------------------24 ------------- Lowest common denom of a/b and c/d
1/6 < 3/8------------------------true------------a/b < c/d
1/6 < = 3/8 -------------------- true------------a/b <= c/d
1/6 > 3/8 -----------------------false------------a/b > c/d
1/6 >= 3/8----------------------false -----------a/b >= c/d
3/8 = 9/24----------------------true-------------a/b = c/d
2/3 X + 2 = 4/5--------------X = -9/5--solution of linear equation (a/b)X = c/d = e/f
Create class that has instance variables for the numerator and the denominator, then overload some functions to achieve the rational number arithmetic.