Q:

In java, how would I make a calculation where the greatest number is subtracted by the smaller number?

If I get two totals as an input, where the first and second number may vary in which is larger, how would I set the calculation to always be the greater number subtracted by the smaller one?

A:

I would use something like that:
public int sub(int firstNumber, int secondNumber) {
    return Math.max(firstNumber, secondNumber) - Math.min(firstNumber, secondNumber);
}

or:
public int sub(int firstNumber, int secondNumber) {
    return Math.abs(firstNumber - secondNumber);
}

A:

substract both and return the absolute value

A:

You could use the following:
Math.abs(a - b)

