Description
In this assignment, the student will write C++ program that implements a “fraction” object. When writing the object, the student will demonstrate mastery of implementing overloaded operators in a meaningful way for the object.
When completing this assignment, the student should demonstrate mastery of the following concepts:
· Mathematical Modeling – Fractions
· Operator Overloading – Binary Operators (Internal Overload)
· Operator Overloading – Binary Operator (External Overload)
Assignment: Write C++ object that implements a “fraction” object. In more precise terms, your object will contain the data needed to represent a rational expression. In mathematics, it is understood that all of the real numbers can be defined as the quotient of two integer values. Your fraction object should contain attributes that represent these two integers. When implementing your fraction object, you should minimally include the following components:
· You should provide a constructor method that initialized the rational expression to (0/1).
· You should provide a constructor method that allows client code to manually set integer values for the numerator and denominator.
· Your object should restrict mutation of itself so only valid rational expressions exist within the object (i.e. a value of 4/0 should be rejected).
· Your object should contain a series of getter and setter methods that allow safe mutation of the numerator and denominator.
· Your getter and setter methods must contain meaningful interfaces that communicate whether values were effectively modified by client code requests through return values. The driver code you write to demonstrate the object should also demonstrate these interfaces.
· Your object should contain overloaded binary arithmetic operators for addition, subtraction, multiplication, and division.
· Your object should always reduce the value represented by the contained rational expression to its lowest terms.
· Your object should contain a binary external operator overload for the stream insertion (<<) operator.
· Your driver code should instantiate a few instances of fractions and demonstrate all the arithmetic operations and displaying the object’s information on the console with overloaded behavior when interacting
with cout (i.e. Your driver should have a statement resembling: cout << myFractionObject;
Madison Hayes –
Thanks. Code is working smooth.