Your program prompts for and accepts the left operand, the operator and the right operand, and then displays the result in numerator/denominator form. The output from your program look[r]
(1)Part C – Encapsulation Class basics - Functions Workshop 5: Fraction Calculator LEARNING OUTCOME
Upon successful completion of this workshop, you will have demonstrated the ability
• a member operator for a class and
• a non-member operator for a class
EXERCISE Fraction Class
Design and code a class named Fraction that holds information about a
rational number Place your class definition in a file named Fraction.h
Upon instantiation, a Fraction may receive two integer values holding the
numerator and denominator of the rational number If the object receives no values, it holds a safe empty state
Include in your class design
• an operator that performs fraction addition,
• an operator that performs fraction subtraction,
• a function that accepts the numerator and the denominator of the rational number from standard input,
• a function that displays the fraction in numerator/denominator form on standard output, and
• an operator that compares two fractions for equality
Define at least one operator as a member function and at least one operator as a non-member function
Name the module that holds your implementation Fraction.cpp
(2)Fraction Calculator
For your main module, write a single expression calculator using your Fraction class Your program accepts any binary expression (that is, an expression that consists of two operands and one operator) Your program prompts for and accepts the left operand, the operator and the right operand, and then displays the result in numerator/denominator form
The output from your program looks something like:
Automatic Reduction
Add a private member function to your Fraction class The member function simplifies the rational number to lowest common denominator form Call this function from your other functions wherever appropriate
The display from a sample run of your revised program might look something like: