Question: Write a C + + program that performs the rational number operations addition, subtraction, multiplication and division on two fractions. The program should be written

Write a C++ program that performs the rational number operations addition, subtraction, multiplication and division on two fractions. The program should be written in a single file. You will need to design a "rational number" class named Rational whose value will be a fraction (e.g.,1/128, or 22/7), with appropriate constructors and member functions. A fraction will be specified as a numerator and a denominator - e.g. the pair (8,109) represents the fraction 8/109. The member variables should be private and accessed using the accessor and mutator functions.
Constructors
Create 3 constructors:
a constructor with two parameters (numerator and denominator)
a constructor with one parameter (denominator set to 1)
a constructor with no parameters (0/1)
Accessor Functions
add
subtract
multiply
divide
display
Mutator Function
simplify
The following are a list of the rules of arithmetic for fractions:
(a/b)+(c/d)=(ad + bc)/(b*d)
(a/b)-(c/d)=(ad - bc)/(b*d)
(a/b)*(c/d)=(ac)/(bd)
(a/b)/(c/d)=(ad)/(cb)

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!