Homework 5, assigned NOV. 5 due NOV. 12 at 11:59pm
Write a program in which the main method calls a method with the heading
public static int subtract(int num) that takes a three digit integer
num> and does the following
- Decomposes it into three digits, digit1, digit2 and
- Using Math.max() and Math.min() determines the digits
with the maximum and minimum value and assign them to maxDigit
and minDigit respectively.
- Using Prog5.java from SEP 24, determines the middle digit and assigns it to
- Constructs an integer, ascend in which these digits appear in
ascending order. For instance, if the original value of num was 673,
the constructed integer would be 367.
- Repeats the last step but this time produces the digits in descending
order. So in our example, it would produce 763. It assigns this to
- Prints these two values.
- Subtracts these two numbers (descend - ascend) and returns this
value in the method.