Question: Assignment 6- Fraction Direction: Submit the typed source codes or git url. Building the Class For this assignment, you will create a fraction class that
Assignment 6- Fraction Direction: Submit the typed source codes or git url. Building the Class For this assignment, you will create a fraction class that can perform every fracion arithmetic operation. The class Fraction should be stored in the beader file "Fraction.h" and should consist of o Private int ficld named numerator Private int field named denominator. o Public default constructor that assigns 1 to both numerutor and denominator. o Public overloaded constructor that takes an int as a parameter named numerator. It assigns sumerator to the numer- ator ficld and 1 to the denominator ficld. Public werkuded constructor that takes two ints au a parameter named numerator and denominator respectively If the exception "Error: Cannot divide by sero"; otherwise, it should assign numerator to fiekds are negative, make them is negative, make it positive and negate (multiply it by negative one) the denomintor equals 0 throw the numcrator field and denominator to the denominator field. Furtbermore, if both both positive. And if the denominator Beld numerator field. o Public copy constructor that perforins a shallow copy. o Public overloaded assigament operator that performs a shallow copy o Public constant get method for numerator. o Public coustaut get method for denominator o Public set method for numerator a Public sct method for denominator. If the parameter is 0 throw the exception "Error: Cannot divide by wero. And if the paramcter is nogative, assign denominator the absolute valuc of the paramcter and nogate the numerator ield. O that takes no parameters. It should return the fraction in decimal o Public double constant method named Dociaal form. o Friend Fraction reference function named Sun() that takes two constant Fraction references as parameters. It returns the sum of the paramcters. The denominator of the sum shonuld be the loast common multiple of the denuminators of the Fraction objocts. o Friend Fraction reference function named Difference) that takes two constant Fraction references as parameters. It returns the difference of the parameters. The denominator of the defference should be the least common multiple of the denuminators of the Fraction objects. returns the product of the parameters. It returns the quotient of the parameters only if the divisor parameter is not 0; otherwise, it throws the exception o Friend Fraction reference function named Product ) that takes two constant Fraction references as parameters. 1 o Friend Complex reference function named Quotient that takes two constant Fraction references as parameters. o Publie string constant method named ToString) that takes no parameters. It should return a string in the format Friend overloaded ostrean operator. It displays a Fraction object in the sume fonnat as ToString( Implementing the Class Error: Cannot divide by zero numerator followed by denominator with a forward slash (/) between them. In the main function, create at lost thre Fraction objects with distinct values. a display each fraction and their decimal forms o display two distinct sums o display two distinct differencos o display two distinct products
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
