I think that if you keep track of numbers as the numerator and denominator (also the wrong fractions - numerators larger than the denominators), this will simplify your task:
public class myFraction { int numerator; int denominator; ... constructors and methods ... }
Then, when you want to do addition and subtraction, you can find the LCD faster and you can work in one view.
If you want to display it as a string, you can easily find the number of integer divisions [t. (numerator / denominator)], and you can find the remainder using either the module:
numerator % denominator + "/" + denominator
or you can save the value that you get from the floor (numerator / denominator) and subtract it from the raw division, which will give you the fractional component (0 <= x <1), i.e.
int myDivision = numerator/denominator; int myFloor = floor(myDivision); int fracComponent = myDivision - myFloor;
the display then looks like
myFloor + " " + mixedNumerator + "/" + denominator
A calculator that I used a long time ago when studying algebra had a display of a mixed fraction and showed the answer as 3u1 / 3 (for "units")
There are several ways to reduce the number of operations in order to get all the facts you need from a number. Do you do decimal manipulations that you have to turn into mixed fractions, or do you start from scratch for input?
I donβt know any Java-API that has built-in functionality, but itβs not too difficult to implement myself and, of course, is a good exercise