Implementing a SMS message count sequence
<p>I am trying to implement a message counter(to count number of characters entered in an SMS), which should count from 160 down to zero(for the first page) increment the second page and then do the count all over again but this time start from 159 down to 0 for subsequent pages. How do I do this</p>

<pre><code>int pgNo;

public int PageNumber(int length, int maxchar) // this is for the page number
    {
        pgNo = ((length / maxchar) + 1);
        return pgNo;
    }

    public int CharCount(int length, int maxchar)// this is for determining the count in that page
    {
        int num = length % maxchar; // num is the count of the page
        if (num == 0 &amp;&amp; length == 0) // checking to determine either 0 or maxchar is to be displayed
        {
            num = maxchar;                // e.g. 0/100 or 100/100
        }
        return maxchar - num;
    }
</code></pre>
