Question: The class should have two private data members: a numerator and a denominator. A function that takes two integers as inputs and sets the numerator

The class should have two private data members: a numerator and a denominator.

A function that takes two integers as inputs and sets the numerator and denominator of the fraction object. The function should check that the denominator is not zero and set the fraction to 0 over 1 if the denominator is zero.

A print function that prints a fraction object as an improper fraction, e.g. 6/4.

A print function that prints a fraction object as a mixed number, e.g. 1 2/4.

A print function that prints a fraction object as a decimal, e.g. 1.5. Each of these print functions should have a different name.

An add function that adds two fractions. Or you could overload the + operator to add fractions.

A subtract function that subtracts two fractions. Or overload the - operator to subtract fractions.

A multiply function that multiplies two fractions. Or overload the * operator to multiply fractions.

A divide function that divides two fractions. Or overload the / operator to divide fractions.

Create the program in C++. Please explain!

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!