When you call the method you are creating new ints. You didn't use x or y at all.
z = num(int val1, int val2);
z = num(x, y);
That will get you the largest between those 2 numbers.
You can just compare z with the next number to get the largest between 3 numbers.