Question: Define the struct Fractional that has the integer components numerator and denominator . Define the class Rational with the private data member number of type

  • Define the struct Fractional that has the integer components numerator and denominator.
  • Define the class Rational with the private data member number of type Fractional. The class also has the public member functions set(), get() which returns a struct variable of type Fractional, print(), multiply() which multiply two rational numbers, and equal() which checks whether two rational numbers are equal or not. The class has a default parametrized constructor with default values 1, 1, Rational(Fractional = {1, 1});
  • Implement all member functions of the class Rational.
  • The following driver produces the given sample of input / output:

Sample input / output:

Enter the numerator and denominator: 3 4

Enter the numerator and denominator: 6 8

The multiplication of 3 / 4 * 6 / 8 = 18 / 32

The two objects are equal

int main()

{

Rational u, v, w;

Fractional temp;

u.set();

v.set();

w = u.multiply(v);

cout

u.print();

cout

v.print();

cout

w.print();

cout

if(u.equal(v))

cout

else

cout

return 0;

}

 Define the struct Fractional that has the integer components numerator and

given sample of inpu Sample input/output: Enter the numerator and denominator: 3 4 Enter the numerator and denominator: 68 The multiplication of 3/4* 6/8 = 18/32 The two objects are equal int main() { Rational u, V, W; Fractional temp; u.set(); v.set(); w=u.multiply(v); cout

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!