Fraction Class

Download Category:

FractionClass_CPP.zip - (4.84 MB)
[
FractionClass_CPP/FractionClass_CPP2010/
FractionClass_CPP/FractionClass_CPP2010/Debug/
FractionClass_CPP/FractionClass_CPP2010/Debug/FractionClass_CPP2010.exe
FractionClass_CPP/FractionClass_CPP2010/Debug/FractionClass_CPP2010.ilk
FractionClass_CPP/FractionClass_CPP2010/Debug/FractionClass_CPP2010.pdb
FractionClass_CPP/FractionClass_CPP2010/FractionClass_CPP2010.sdf
FractionClass_CPP/FractionClass_CPP2010/FractionClass_CPP2010.sln
FractionClass_CPP/FractionClass_CPP2010/FractionClass_CPP2010.suo
FractionClass_CPP/FractionClass_CPP2010/FractionClass_CPP2010/
FractionClass_CPP/FractionClass_CPP2010/FractionClass_CPP2010/Debug/
FractionClass_CPP/FractionClass_CPP2010/FractionClass_CPP2010/Debug/cl.command.1.tlog
FractionClass_CPP/FractionClass_CPP2010/FractionClass_CPP2010/Debug/CL.read.1.tlog
FractionClass_CPP/FractionClass_CPP2010/FractionClass_CPP2010/Debug/CL.write.1.tlog
FractionClass_CPP/FractionClass_CPP2010/FractionClass_CPP2010/Debug/Fraction.obj
FractionClass_CPP/FractionClass_CPP2010/FractionClass_CPP2010/Debug/FractionClass_CPP2010.exe.intermediate.manifest
FractionClass_CPP/FractionClass_CPP2010/FractionClass_CPP2010/Debug/FractionClass_CPP2010.lastbuildstate
FractionClass_CPP/FractionClass_CPP2010/FractionClass_CPP2010/Debug/FractionClass_CPP2010.log
FractionClass_CPP/FractionClass_CPP2010/FractionClass_CPP2010/Debug/link.command.1.tlog
FractionClass_CPP/FractionClass_CPP2010/FractionClass_CPP2010/Debug/link.read.1.tlog
FractionClass_CPP/FractionClass_CPP2010/FractionClass_CPP2010/Debug/link.write.1.tlog
FractionClass_CPP/FractionClass_CPP2010/FractionClass_CPP2010/Debug/Main.obj
FractionClass_CPP/FractionClass_CPP2010/FractionClass_CPP2010/Debug/mt.command.1.tlog
FractionClass_CPP/FractionClass_CPP2010/FractionClass_CPP2010/Debug/mt.read.1.tlog
FractionClass_CPP/FractionClass_CPP2010/FractionClass_CPP2010/Debug/mt.write.1.tlog
FractionClass_CPP/FractionClass_CPP2010/FractionClass_CPP2010/Debug/vc100.idb
FractionClass_CPP/FractionClass_CPP2010/FractionClass_CPP2010/Debug/vc100.pdb
FractionClass_CPP/FractionClass_CPP2010/FractionClass_CPP2010/Fraction.cpp
FractionClass_CPP/FractionClass_CPP2010/FractionClass_CPP2010/Fraction.h
FractionClass_CPP/FractionClass_CPP2010/FractionClass_CPP2010/FractionClass_CPP2010.vcxproj
FractionClass_CPP/FractionClass_CPP2010/FractionClass_CPP2010/FractionClass_CPP2010.vcxproj.filters
FractionClass_CPP/FractionClass_CPP2010/FractionClass_CPP2010/FractionClass_CPP2010.vcxproj.user
FractionClass_CPP/FractionClass_CPP2010/FractionClass_CPP2010/Main.cpp
FractionClass_CPP/FractionClass_CPP2010/ipch/
FractionClass_CPP/FractionClass_CPP2010/ipch/fractionclass_cpp2010-64ea7287/
FractionClass_CPP/FractionClass_CPP2010/ipch/fractionclass_cpp2010-64ea7287/fractionclass_cpp2010-f769be1d.ipch
FractionClass_CPP/Question.txt
FractionClass_CPP/Screenshot.png
]

Write a Fraction class that overloads the arithmetic operators (+, -, *, /). Minimally, your fraction class should include the following methods that behave as directed:

Fraction()
This is a default constructor for the fraction class. It should load a value of 1 into the denominator and a value of 0 into the numerator

Fraction(int numerator, int denominator)
This is an overloaded version of the constructor. It accepts inputs for the numerator and denominator and creates a fraction that starts out with those values. Be mindful to sanitize the input to ensure a zero is not loaded into the denominator.

int getNumerator()
This is a getter method for the numerator.

void setNumerator()
This is a setter method for the numerator.

int getDenominator()
This is a getter method for the denominator.

void setDenominator()
This is a setter method for the denominator. Ensure the user enters valid values for this (no zeros allowed!).

void Reduce()
This method should reduce the contents of the fraction. The resultant fraction should be an equivalent, improper fraction in lowest terms (no mixed numbers).

Fraction operator+(Fraction addMe)
This method implements behavior for the addition operator. Your driver should clearly demonstrate the use of this operator.

Fraction operator-(Fraction subtractMe)
This method implements behavior for the subtraction operator. Your driver should clearly demonstrate the use of this operator.

Fraction operator*(Fraction multiplyMe)
This method implements the behavior for the subtraction operator. Your driver should clearly demonstrate the use of this operator.

Fraction operator/(Fraction divideMe)
This method implements behavior for the division operator. Your driver should clearly demonstrate the use of this operator.

Remember to call your reduction method every time you perform an operator on a fraction. This will ensure that the resultant Fraction is in lowest terms.
Remember to sanitize inputs for your Fractions. A denominator of zero should never be allowed at anytime. If the client code attempts to load a zero into a denominator, you should print a message informing the user that this has occurred. Additionally, you should make a decision about the action the program takes in terms of picking a value to assign to the denominator when such an errors occurs. The best course of action is probably to change nothing and just display a message to the user.

Write a Review

Get a fresh solution of this question. Ask it now to our experts.
doubt

Ask Your Question

We have verified professionals who are ready to answer your question.

time

Save Time and Money

We choose experts who can quickly answer your question and that suit your budget.

download

Get Your Answer

Your satisfaction is 100% guaranteed. You can keep on asking questions until you get the answer you need.