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

There are a lot of solutions out there but can you please use the (stringstream)

ID: 3799641 • Letter: T

Question

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:

Explanation / Answer

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();
}