**Homework 5, assigned :**

MON WED class: WED OCT 31 and part A is due MON NOV 12 at 11:59pm

TUE THU class: THU NOV 1 and part A is due TUE NOV 13 at 11:59pm

MON WED class: part B is due WED NOV 14 at 11:59pm

TUE THU class: part B is due THU NOV 15 at 11:59pm

### Part A

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`, for instance 123, and does the following

- Decomposes it into three digits,
`digit1, digit2` and
`digit3`. One of the ways you can do this is by using
String s = "" + num, and then use
s.charAt(0), s,charAt(1), s.charAt(2) to gets the digits.
- Using
`Math.max()` and `Math.min()` determines the digits
with the maximum and minimum value and assign them to `maxDigit`
and `minDigit` respectively.
- Using Prog6.java from OCT 25, determine the middle digit and
assigns it to
`midDigit`.
- 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
`descend`.
- Prints these two values.
- Subtracts these two numbers (
`descend - ascend`) and returns this
value in the method.

### Part B

- Write another program that calls method
`subtract` defined in part A
from the main method until the method returns a value that doesn't change,
i.e., 495. Try the following approach. Before the loop assign 123 (or any other
3-digits number different from the one we describe next) to "previous" and 149
(or another 3-digit number in which all the digits are different) to "present".
Your program should print the value of "present".
Construct the while loop as follows:**
**while( previous != present)
{
previous = present;
........ = subtract(...);
}

**
**