Question: Project 3B: Designing and implementing a C++ class data type: Fraction Class A multifile project Write a fraction class whose objects will represent fractions. You
Project 3B: Designing and implementing a C++ class data type: Fraction Class
A multifile project
Write a fraction class whose objects will represent fractions. You should provide the following member functions:
Two constructors, a default constructor which assigns the value 0 to the fraction, and a constructor that takes two parameters. The first parameter will represent the initial numerator of the fraction, and the second parameter will represent the initial denominator of the fraction. (6 pts for specification and implementation)
Arithmetic operations that add, subtract, multiply, and divide fractions. These should be implemented as four value returning functions that return a fraction object. They should be named AddedTo,Subtract, MultipliedBy, and DividedBy. Note the returned fraction object must be in reduced form. (20 pts for specification and implementation)
A boolean operation named isGreaterThan that compares two fraction objects to determine whether one fraction object is greater than the other. (5 pts for specification and implementation)
An input operation named getFraction that prompts the user for two integer values to be used to define a new fraction object. One value is to be used for the numerator and the other for the denominator of the fraction object. on the screen in the form numerator/denominator. (5 pts for specification and implementation)
An output operation named showFraction that displays the value of a fraction object on the screen in the form numerator/denominator. (4 pts for specification and implementation)
NOTE: You may not implement the above member functions as inline functions but should include the function member declarations (or prototypes) in the class specification file (fraction.h) and then write the member function definitions in the implementation file (fraction.cpp).
Your class specification should name the class fraction (not Fraction) and should have exactly two data members, one to represent the numerator of the fraction being represented, and one to represent the denominator of the fraction being represented.
When adding or subtracting fractions, remember that you must first find the common denominator. The easy way to do this is to multiply the denominators together and use that product as the common denominator.
I am providing a client program for you below. You should copy and paste this into a file and use it as your client program (client.cpp) that will be a part of your mutlitfile project. The output that should be produced when the provided client program (client.cpp) is run with your completed class specification (fraction.h) and implementation files (fraction.cpp) is provided below, so that you can check your results. Since this project requires multiple files you will need to first create a new project in your compiler and then write the source code for your class specification file, the implementation file and then add the client code below to the project. For an example with explanations of such C++ class related multifile projects review the Software Engineering Tip: Seperating Class, Specification, Implementation, and Client Code in Chapter 7.11 in your Gaddis textbook (pgs. 446-452)
I strongly suggest that you design your fraction class incrementally. For example, you should first implement only the constructors and the output function, comment out portions of the client code that is not needed and then test what you have so far. Once this code has been thoroughly debugged, you should then add additional member functions, testing each one thoroughly as it is added. You might do this by creating your own client program to test the code at each stage; however, it would probably be better to use the provided client program below and comment out portions of code that relates to member functions that you have not yet implemented.
Here is the client program (save the contents below onto a new file client.cpp)
/*Client.cpp is set-up as a fraction class implementation and test driver program - DO NOT CHANGE SOURCE CODE All necessary class objects are declared and defined here to test various class related operations. HINT: see comments for specific class related function calls*/ #include#include "fraction.h" using namespace std; int main() { fraction f1(9,8); //calling a parameterized class constructor fraction f2(2,3); fraction result; //calling a default class constructor const fraction f3(12, 8); const fraction f4(202, 303); fraction f5,f6; cout As you can see from the sample output given below, except for the arithmetic operations you are not required to change improper fractions into mixed numbers for printing. Just print it as an improper fraction. You are, however, required to reduce fractions that are the result of an arithmetic operation. See the reduced fraction result for the multiplication and division in the sample output. You are not required to deal with negative numbers, either in the numerator or the denominator.
Compiling/running the client program (client.cpp) above along with the fraction class specification (fraction.h) and implementation file (fraction.cpp) should produce the output shown below:
C++ CLASS MULTI-FILE PROJECT Client.cpp - testing a fraction class implementation ---------------------------------------------------- The result object starts off at 0/1 Arithmetic operations with fraction objects stored in the results class object ------------------------------------------------------------------------------ The sum of 9/8 and 2/3 is 43/24 The difference of 9/8 and 2/3 is 11/24 The product of 9/8 and 2/3 is 3/4 The quotient of 12/8 and 202/303 is 9/4 Input and Output operations for two new class objects ----------------------------------------------------- Enter values for a fraction object Numerator: 12 Denominator: 13 12/13 Enter values for a fraction object Numerator: 5 Denominator: 6 5/6 A Boolean operation comparing two class objects ------------------------------------ 12/13 is greater than 5/6 --------------------------------------------------------- Fraction class implementation test now successfully concluded Process returned 0 (0x0) execution time : 10.546 s Press any key to continue.After successfully completing this mutifile C++ class project (ie., your program output should match the above), use the file submission area and upload just two source code files (1) the "fraction class" specification file (fraction.h), followed by source code for your "fraction class" implementation file (fraction.cpp). No need to submit the client code or the output produced when you ran your mutlitfile C++ class project using the client program above. You may comment out portions of the client code as you incrementally build and test your fraction class specification and implementation code but do not change the client program in any way for the final version. Changing the client program will result in a grade of 0 on the project.
*important reminder: for multi-file projects to work in your C++ compiler/IDE environment ....make sure you create a new project folder and place all related files in the same folder. Also check that you have the appropriate #include statements in the class implementation and client code files. Xcode users should place these files in the debug folder.
You may find a review of the instructor provided sample Abstract DataType project called "MoneyType" helpful when working on this - "Fraction class project".... follow this link => Abstract_Data_Type.pdf
(see also Weeks 6-7 Lecture Videos and Class Handouts page and a review of some of the lecture/lab pre-recorded sessions on classes along with sample source code may be helpful).
Please also make sure to include appropriate function documentation as needed (see handout on Function Documentation: Assertions and Dataflow comments) and separate your member functions definitions in the implementation file with at least 1 inches of whitespace. You must also include the constant key words for all member functions that are "observer type" of functions. DO NOT use global variables and inline member functions.
Your working project 3B folder in your C++ compiler should have the following files: fraction.h (class specification file) fraction.cpp (class implementation file) client.cpp (client code using the fraction class)
Submit your source code for fraction.h and fraction.cpp only. DO NOT submit the client code already provided in the project specification. Before you submit the two required files, make sure that you have included your name in the comment area at the top of both the fraction.h and fraction.cpp files.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts

(see also Weeks 6-7 Lecture Videos and Class Handouts page and a review of some of the lecture/lab pre-recorded sessions on classes along with sample source code may be helpful).