Java classes to calculate the fractionc