Question: c++ program . comment and explain the formula 7. (20 points) Write a class named Rat (to simulate rational or fraction number) such that it
7. (20 points) Write a class named Rat (to simulate rational or fraction number) such that it works as in the main below. int main() { Rat a(3, 4), (1, 2); a.print(); // output: 3/4 b.print(); // output: 1/2 Rat c-a.add(b): c.printo: // output: 5/4 // Hint: 3/4 + 1/2 - 6/8 + 4/8 - 10/8 - 5/4 Rat d = a.multiply(b); d.print(): // output: 3/8 // Hint: 3/4 x 1/2 - 3/8 return 0
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
