The calculator first identifies the values that you input for the numerator and denominator of each fraction. It then assigns them to the following variables: top1, bottom1, top2, and bottom2. Next, it determines which operation you would like to perform by checking the four radio buttons. Depending on which radio button you selected, it performs one of four calculations:

After performing one of the above calculations, the calculate now has a new top and a new bottom, called topR and bottomR, where R stands for "Result." Before we display the answer, we need to complete the last step: reduce the fraction.

Because the calculator performed the operations with the original values, the fractions can be quite large - so it runs a "loop" to determine the simplest form of the fraction. Once it finds the simplest form, it displays the simplified numerator and the simplified denominator. Finally, it puts a red circle around the answer to show you it is complete!