C problem 1Complete the implementation of the given Fraction

C++ problem:

1.Complete the implementation of the given Fraction class

Notes :

You are not allowed to make any change to the given Fraction class.

make sure that there is NO common factors between *numerator and *denominator.

if the Fraction is negative, the negative sign always goes to *numerator , *denominator always greater than or equal to 1 .

for the output operator << ,

if *denomiator is equal to 1 , the denominator will not be displayed. (i.e. 2 instead of 2/1 )

if the Fraction is negative, make sure that negative sign always goes with numerator ( i.e. -2/3 instead of 2/-3 )

2.Implement a test driver (main) that enable user to test all the features implemented in the Fraction class.

Solution

// Everything divides 0

    if (m == 0 || n == 0)

       return 0;

    // base case

    if (m == n)

        return m;

    // a is greater

    if (m > n)

        return gcd(m-n, n);

    return gcd(m, n-m);

C++ problem: 1.Complete the implementation of the given Fraction class Notes : You are not allowed to make any change to the given Fraction class. make sure tha

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site