Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing Fundamentals Design And Implementation

Authors: KROENKE DAVID M.

1st Edition

8120322258, 978-8120322257

More Books

Students also viewed these Databases questions