Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

// driver for project 5 #include using namespace std ; #include Frac2.h int main () { Fraction c( 7 , 3 ) , d( 3

// driver for project 5

#include

using namespace std;

#include "Frac2.h"

int main() {

Fraction c(7, 3), d(3, 9), x;

// c.printFraction();

cout c;

cout " + ";

// d.printFraction();

cout d;

cout " = ";

x = c + d;

// x.printFraction();

cout x;

cout ' ';

// c.printFraction();

cout c;

cout " - ";

// d.printFraction();

cout d;

cout " = ";

x = c - d;

// x.printFraction();

cout x;

cout ' ';

// c.printFraction();

cout c;

cout " * ";

// d.printFraction();

cout d;

cout " = ";

x = c * d;

// x.printFraction();

cout x;

cout ' ';

// c.printFraction();

cout c;

cout " / ";

// d.printFraction();

cout d;

cout " = ";

x = c / d;

// x.printFraction();

cout x;

cout ' ';

// c.printFraction();

cout c;

cout " is: ";

cout ((c > d) ? " > " : " );

// d.printFraction();

cout d;

cout " according to the overloaded > operator ";

cout ((c d) ? " : " >= ");

// d.printFraction();

cout d;

cout " according to the overloaded ";

/* uncomment this line for improved version

// Optional: 2 Bonus Points

// c.printFraction();

cout

cout

// d.printFraction();

cout

cout

cout

cout

cout

cout

cout

cout

x = c + c / d - d * c; // cascading use of operators

// x.printFraction();

cout

cout

*/ // uncomment this line for improve version

#ifdef _WIN32 // _WIN32 is used by visual C++

#if (_MSC_VER

system("pause");

#endif

#endif

return 0;

}

image text in transcribed
image text in transcribed
CMPSC122 Lab Proj 5 - Overloading Operators, Stream, and String Classes Project 5. Building a class for Fraction ADT Phase 2 ( 20 points. submit your two source files named Frac2.cpp and Frac 2.h online only before the due time next week) This assignment is the continuation of project 4 , with the modification and improvement of the following modifications: - In Frac.h, replace the methods of addition (const Fraction \&), subtraction(const Fraction\&), multiply( const Fraction \&), divide(const Fraction \&), void printFraction() by overloading operators +,,,1, respectively. - Add overloading operators > and 1/3 according to the overloaded > operator >=1/3 according to the overloaded

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions