Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Exercise :- Read the documentation of the header file carefully. Four of the fun

ID: 3543980 • Letter: E

Question

Exercise :- Read the documentation of the header file carefully. Four of the function

implementations have documentation and the others do not. Explain how these four

are different.


Exercise :- Fill in the missing code in the implementation file, and compile

fraction.cpp. Were there many bugs in your file? Describe any problems that you

had.


Exercise :- Write a driver that uses class Fraction to do the following calculations:

1/2 + 1/4

1/2 1/4

1/2 * 1/2

1/2 / 1/2

Write the output clearly labeled.



// Header file fraction.h declares class Fraction.

class Fraction

// Class Fraction represents the numerator and

// denominator of a fraction.

{

public:

// Constructors

Fraction();

// Post: Numerator and denominator have been set to zero

Fraction(initNumerator, initDenominator);

// Post: Numerator has been set to initNumerator;

// denominator has been set to initDenominator.

Fraction Add(Fraction frac1) const;

// Post: self + frac1 is returned.

Fraction Subtract(Fraction frac1) const;

// Post: self - frac1 is returned.

Fraction Multply(Fraction frac1) const;

// Post: self * frac1 is returned.

Fraction Divide(Fraction frac1) const;

// Post: self / frac1 is returned.

int GetNumerator() const;

// Post: Numerator of frac1 is returned.

int GetDenominator() const;

// Post: Denominator of frac1 is returned.


private:

int numerator;

int denominator;

};

____________________________________________________________

//*******************************************************


// Implementation file fraction.cpp implements the member

// functions of class Fraction.


#include "fraction.h"

Fraction::Fraction()

{

// FILL IN Code for default constructor.

}


Fraction::Fraction(initNumerator, initDenominator)

{

// FILL IN Code for default constructor.

}


Fraction Fraction::Add(Fraction frac1) const

// Pre: frac1 and self have been initialized.

// Post: frac1 + self is returned in reduced form.


{

// FILL IN Code.

}


Fraction Fraction::Subtract(Fraction frac1) const

// Pre: frac1 and self have been initialized.

// Post: self - frac1 is returned in reduced form.are

{

// FILL IN Code.

}


Fraction Fraction::Multiply(Fraction frac1) const

// Pre: frac1 and self have been initialized.

// Post: self - frac1 is returned in reduced form.are


{

// FILL IN Code.

}


Fraction Fraction::Divide(Fraction frac1) const

// Pre: frac1 and self have been initialized.

// Post: self - frac1 is returned in reduced form.are


{

// FILL IN Code.

}


int Fraction::GetNumerator() const

{

// FILL IN Code.

}


int Fraction::GetDenominator() const

{

// FILL IN Code.

}


Explanation / Answer

https://www.dropbox.com/sh/1j2sh79j3mo19qb/RVf6IghOj_

Download the complete working code from the above link..
I have have also provided a pic of my command prompt to show the working example of the code..

please give the feedback in comments..
Thank You

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote