There are a lot of solutions out there but can you please us

There are a lot of solutions out there but can you please use the (stringstream) for the last part of the program instead of returning, exampl: (return to_string(num) + \"/\" + to_string(den);
   else
       return to_string(num)

The C++ class FullFraction, discussed in class and outlined here. Test your implementation with the assign_FullFraction() code below.(No header file,all code in one file)

Maintain fractions internally in lowest terms - the best place to do this is in setFraction()

Be sure to maintain the sign of the fraction correctly

Avoid a 0 in the denominator by forcing the fraction to 0

Enhance toString() to display a mixed fraction (whole numbers and fraction) when the numerator is greater than the denominator


The output of the test driver is:

Solution

Hi, Please find my implementation.

Please let me know in case of any issue.

std::string FullFraction::toString(){
ostringstream ss;
if(denominator < 0){
numerator = (-numerator);
denominator = (-denominator);
}

if(denominator == 1)
ss<<numerator<<\" \"<<numerator;
else
ss<<numerator << \"/\" << denominator << \" \" << (numerator/denominator);

return ss.str();
}

There are a lot of solutions out there but can you please use the (stringstream) for the last part of the program instead of returning, exampl: (return to_strin

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site