#### Details of this Paper

##### Fraction_Operator_Overload_CPP

**Description**

solution

**Question**

Electronic submission: You must submit a single.zip file containing only the source file(s).;Use a utility that produces.zip files (Windows/Mac compression utility), and include only source;files (.cpp,.h) and text files (.txt).;Objectives;? To create a class that uses operator overloading.;P;roject setup;Use your IDE to create the project hw05.;R;efer to the appropriate "how to" tutorial notes available on the course website, for instructions;on how to create a project and manage its files.;Language features used;? classes, operator overloading;P;roblem Description;In this programming assignment you are to create a class Fraction, to store and manipulate;fractions. You will overload some operators and test the class out.;Implementation requirements;(1) Create the class Fraction to store a fraction as two distinct values, one for the numerator;and one for the denominator. This time around the fields should be integer values.;(2) Add the necessary ctor(s) and accessor methods.;(3) Add a toString() method per usual.;(4) Add a private method int gcd() const, to return the greatest common divisor. The;algorithm based on our old friend Euclid is given below, so just copy paste or type into your;own class.;(5) Add a method that returns the value of the fraction as a decimal value.;(6) Add a method that reduces the fraction to its simplest form, e.g. 2/4 becomes 1/2. Use the;gcd() method to help you out.;(7) Add all the relational operators (==, !=, =).;(8) Add the four arithmetic operators (+, -, *, /).;(9) Add the two operators () as functions. The output operator simply displays the;fraction as n/d and the input operator reads the numerator and then denominator from the;keyboard. See the screenshot below.;(10) Test the class in the driver using the sample output given below as a guideline.;Administrative Requirements;As you write your programs from here on out, documentation will be desirable and an essential;part of your code. Add the following section to each of your programs to identify relevant;information to anyone reading your code. The sample below is what I used for main.cpp, so;make the appropriate changes to reflect your current/accurate information. This is just a;sample, so feel free to add to it if you want, but do not remove anything.;/* File: main.cpp;* Name: Socratis Tornaritis;* Revised: 8/16/2014;* Course: CS240 - Introduction to Computing III - Fall 14;*;* Desc: This program;*/;? Make sure your output is formatted exactly as shown.;? Upload and save your upload using Moodle by the due date.;? If your program fails to compile for whatever reason, it will automatically incur an 11%;penalty. Please seek help if you are having problems getting your program to compile or;run successfully.;# / #;Last updated: September 2 2 25, 2014 at 6:05 PM;int Fraction::gcd() const;int n = numerator;int d = denominator;int tmp;while (d != 0);tmp = n % d;n = d;d = tmp;return n;// end gcd();f1 = 3/6, f2 = 4/5 !;f1 + f2 = 39/30 = 13/10 = 1.3;f1 - f2 = -9/30 = -3/10 = -0.3;f1 * f2 = 12/30 = 2/5 = 0.4;f1 / f2 = 15/24 = 5/8 = 0.625 !;Enter a fraction [numerator denominator]: 2 5

Paper#65586 | Written in 18-Jul-2015

Price :*$32*