Why is the solution like this?
<p>From Java Malik textbook- determine if an number is divisible by 11..</p>

<p>Code Solution provided:</p>

<pre><code>import java.util.*;

public class Divby11
{
    static Scanner console = new Scanner(System.in);

    public static void main (String[] args)
    {
        int num, temp, sum;
        char sign;

        System.out.print("Enter a positive integer: ");
        num = console.nextInt();
        System.out.println();

        temp = num;

        sum = 0;
        sign = '+';

        do
        {
            switch (sign)
            {
            case '+' :
                sum = sum + num % 10;
                sign = '-';
                break;

            case '-' :
                sum = sum - num % 10;
                sign = '+';
            }

            num = num / 10;       //remove the last digit
        }
        while (num &gt; 0);

        if (sum % 11 == 0)
            System.out.println(temp + " is divisible by 11");
        else
            System.out.println(temp + " is not divisible by 11");
    }
</code></pre>

<p>Why go through all the effort above and just say...</p>

<pre><code>  if (sum % 11 == 0)
            System.out.println(temp + " is divisible by 11");
        else
            System.out.println(temp + " is not divisible by 11");
</code></pre>

<p>Can any of you experts see why the author would do it this way (long way)?</p>
