Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

TextEdit File Edit Format View Window Help alld For this assignment you will be building on your Fraction Class. However, the changes will be significant,

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
TextEdit File Edit Format View Window Help alld For this assignment you will be building on your Fraction Class. However, the changes will be significant, so I would recommend your previous version as a resource when appropriate. You'l continue working on your Fraction class for o starting from scratch and usi one more week, next week. For this week you are no provide documentation and not required to simplify Fractions Please keep all of your code in one file for this week. We will separate things into three files for the next assignment Here are the client program and correct output Your class should support the following operations on Fraction objects: Construction of a Fraction from two, one, or zero integer arguments. If two arguments, they are assumed to be the numerator and denominator, Just o to be a whole number, and zero arguments creates a zero Fraction. Use defauit parameters so that you only need a single function to impleme all three of these constructors. You should check to make sure that the denominator is not set to O. The easiest way to do this is to use an assert statement: a You can put this statement at the top of your constructor. Note that the variable in the asserto) is the incoming parameter, not the data member. In ord to use assert(), you must einclude ccassert> For this assignment, you may assume that all Fractions are positive. We'll fix that next week. ssertonenominator ! a Fraction to a stream with an overloaded cs operator. Next week we will get fancy with this, but for now just print the numerator, a forward the relational operators (,_, >.>,--, t-) should be supported. They should be able to compare Fractions toother Fractions as well as to integers. Either Fractions or integers can appear on either side of the binary comparison operator. You should only use one function for eadch supported. Again, they should allow Fractions to be combined with other Fractions, as well as The four basic arithmetic operations (+, /) should be ntegers. Either Fractions or integers can appear on either side of the binary operator. Only use one function for each operator Note that no special handling is needed to handle the case of dividing by a Fraction that is equal to 0. If the c is the same behavior they would expect if they tried to divide by an int or double that was equal to . The shorthand arithmetic ssserment operators(,)should aliso be implemented. Fractions can appear on the left-hand side, and Fractions ) operators should be supported in both prefix and postfix form for Fractions. To increment or decrement a Fractic integers on the right-hand side. - The increment and decrement ( means to add or subtract (respectively) one (1) acttest.cap include include catring using nanespace std; void Basietest) void Relationtest0 void ninaryhathTest)i strinm boo1string(bool convertxe) Basieteat) RelationTest ninaryMathTeat)r MathAssiqnTeat) woid Dasictest) ceut ce ITesting basio Fraction ereation&printingin conat Fraction fr[l1- (Fraetion(4,8),Fraction(-15,2) Fraction( 10), Fraction(12, -3) Tractiont), rraction(28, 6), Fractionto, 12))

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

Programming The Perl DBI Database Programming With Perl

Authors: Tim Bunce, Alligator Descartes

1st Edition

1565926994, 978-1565926998

More Books

Students also viewed these Databases questions