Write anbspfractionnbspclass whose objects will represent


Write a fraction class whose objects will represent fractions. You should provide the following member functions:

  1. Two constructors, a default constructor which assigns the value 0 to the fraction, and a constructor that takes two parameters. The first parameter will represent the initial numerator of the fraction, and the second parameter will represent the initial denominator of the fraction.
  2. Arithmetic operations that add, subtract, multiply, and divide fractions. These should be implemented as value returning functions that return a fraction object. They should be named addedTo, subtract, multipliedBy, and dividedBy.
  3. A boolean operation named isEqualTo that compares two fraction objects for equality.
  4. An output operation named print that displays the value of a fraction object on the screen in the form numerator/denominator.

Your class should have exactly two data members, one to represent the numerator of the fraction being represented, and one to represent the denominator of the fraction being represented.

When adding or subtracting fractions, remember that you must first find the common denominator. The easy way to do this is to multiply the denominators together and use that product as the common denominator.

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: Write anbspfractionnbspclass whose objects will represent
Reference No:- TGS01090355

Expected delivery within 24 Hours