Question: // // testFraction.cpp // // DO NOT MODIFY THIS FILE // #include Fraction.h #include using namespace std; void print_fraction(const Fraction& f) { cout } int

 // // testFraction.cpp // // DO NOT MODIFY THIS FILE //

//

// testFraction.cpp

//

// DO NOT MODIFY THIS FILE

//

#include "Fraction.h"

#include

using namespace std;

void print_fraction(const Fraction& f)

{

cout

}

int main()

{

Fraction w;

w = 4;

Fraction x(4,6);

Fraction y(5,6);

Fraction z(0);

cout

cout

cout

cout

cout

cout

cout

cout

cout

cout

cout

cout

cout

cout

cout

cout

cout

cout

print_fraction(y);

try

{

cout

}

catch ( invalid_argument& e )

{

cout

}

cout

Fraction u(12,18);

print_fraction(u);

}

Makefile:

# DO NOT MODIFY THIS FILE CXX=g++ CXXFLAGS=-Wall EXECS=testFraction all: $(EXECS) testFraction: testFraction.o Fraction.o $(CXX) -o $@ $^ clean: rm -f *.o $(EXECS)

output:

w = 4 x = 2/3 y = 5/6 z = 0 x+y = 3/2 x-y = -1/6 x*y = 5/9 x/y = 4/5 -x = -2/3 x+2 = 8/3 2+x = 8/3 x-2 = -4/3 2-x = 4/3 2*x = 4/3 x*2 = 4/3 x/2 = 1/3 2/x = 3 w+x+y = 11/2 print_fraction: 5/6 x / z = Exception: zero denominator 2 * ( x + y ) = 3 print_fraction: 2/3

Description Create a simple Fraction class that can be used in a C++ program to perform addition, subtraction, multiplication and division of rational numbers. Implementation You will design and implement a class Fraction that encapsulates all functions related to the processing of fractions. The , including an appropriate message (see testFraction.out to identify the message)

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!