Question: Problem Create a class named Fraction containing two integer data members named num and denom used to store the numerator and denominator of a fraction

Problem

Create a class named Fraction containing two integer data members named num and denom used to store the numerator and denominator of a fraction having the form num/denom.

Specification

1. Include default and parametrized constructors.

The default constructor should initialize num and denom to 1.

Neither constructor should allow a 0 denominator value.

2. Overload operator functions for

addition +: a/b + c/d = (a * d + b * c) / (b * d)

subtraction -: a/b - c/d = (a * d - b * c) / (b * d)

multiplication *: a/b * c/d = (a * c) / (b * d)

division /: a/b / c/d = (a * d) / (b * c)

stream insertion: << to send a fraction to the screen.

stream extraction: >> to input a fraction from the keyboard.

3. Include the class in a C++ program that tests each member function.

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!