Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I just need help with the print function!!please! //fraction.cc #include<iostrea

ID: 3611635 • Letter: I

Question

I just need help with the print function!!please!


//fraction.cc
#include<iostream>
#include"fraction.h"
using namespace std;


Fraction::Fraction()
   {
       //Sets default values forFraction Class
       num=0;
       den=1;
   }

void Fraction::print()
   {
//????
//Write Function to output num/den
//????

  
   }
void Fraction::SetNum(int n_new)
   {
       //@pre call to set thenumerator
       //@post the new numerator isset
       num = n_new;
   }  
void Fraction::SetDen(int d_new)
   {
       //@pre call to set thedenominator
       //@post negative valuechecked and set new denominator
       den = d_new;
       if(den < 0)
       {
           num *=-1;
           den *=-1;
       }
   }
void Fraction::SetFrac(int Fracnum)
   {
       //@pre Fraction is defined,and program seeks input from user.
       //@post User entered twovalues and if the denominator is
       //negative it is madepositive.
       int n_new = 0;
       int d_new = 0;
       cout<<"Enter a valuefor the numerator in Fraction"<<Fracnum;
       cout<<endl;
       cin>> num;
       cout<<"Enter a valuefor the denominator in Fraction"<<Fracnum;
       cout<<endl;
       cin>> den;
      
       if(den < 0)
       {
           //Get rideof negative denominators when they are inputted.
           //Couldhave a separate func for this, but it is the easiest
           //to doright when the values are inputed.
           num *=-1;
           den *=-1;
       }
   }
Fraction Fraction::operator +(Fraction d)
   {
       //@pre function is given twofractions to add.
       //@post function returns theadded value of fractions.
       Fraction added_frac;
       added_frac.num = (num *d.den) + (d.num * den);
       added_frac.den = d.den *den;
       return(added_frac);
   }
Fraction Fraction::Fraction_Operator(int operation, Fraction a,Fraction b)
   {
       //@pre Funcition is givenoperation and two Fractions.
       //@post Function completesthe operation and returns to client.
       Fraction ret_clnt;

       //Yes, I know that a switchhere is presently pointless.
       //But, if I want to later addsay a subtract or divide opertaion
       //then it would already beset up.
       switch(operation)
       {
           caseFRAC_ADD:
              return (a+b);
       }
       ret_clnt.SetNum(1);
       ret_clnt.SetDen(1);
       return(ret_clnt);
   }
int Fraction::GCD(int GCD_num, int remainder)
   {
       //@pre Function is given thevalues of the numerator and denominator
       //@post Function returns thegreastest common denominator(factor)
       //to the client
       if(remainder == 0)
           return(GCD_num);
       else
           return(GCD(remainder,GCD_num%remainder));
   }
float Fraction::decimal(Fraction a)
   {
       //@pre function is given onefraction to find the decimal value.
       //@post function returns thedecimal value of given fraction.
       float fracnum =a.num;
       float fracden = a.den;
       float dec_val = fracnum /fracden;
       return(dec_val);
   }
void Fraction::reduce()
   {
       //@pre Function is given afraction to reduce
       //@post Function has beenreduce to its smallest.
       int red_val = 0;
       if(den > num)
           red_val =GCD(den, num);
       else if(den < num)
           red_val=GCD(num, den);
       else
           red_val =GCD(num, den);
       num /= red_val; //Simplifiesnumerator
       den /= red_val; //SImplifiesdenominator
   }

Explanation / Answer

Those lines should work. What error are you getting?