Java Change Calculation
<p>Please I got a change algorithm calculation which adds up instead of subtracting the amount paid by the user . i want the program to be able to deduct the amount paid from the textbox using a set of currency buttons and when the amount is over paid, a balance should be returned back to the user. it instead adds up each time i click on any of the currency buttons using the message box. Thanks</p>

<p>These are the currency buttons:</p>

<pre><code>      private void tenPoundButtonActionPerformed(java.awt.event.ActionEvent evt) {                                               
    // TODO add your handling code here:
    amountToPay -= 1000;
    calculate(amountToPay);
}                                              

private void twentyPoundButtonActionPerformed(java.awt.event.ActionEvent evt) {                                                  
    // TODO add your handling code here:
    amountToPay -= 2000;
    calculate(amountToPay);
}                                                 

private void fiftyPoundButtonActionPerformed(java.awt.event.ActionEvent evt) {                                                 
    // TODO add your handling code here:
    amountToPay -= 5000;
    calculate(amountToPay);
}         
</code></pre>

<p>this is the change algorithm :</p>

<pre><code>    public void calculate(double amount) {

    if (amount &gt; 0) {
        amountPaidTextBox.setText(pounds.format(amount/100));
    }
    else {
        amountPaidTextBox.setText("");

        if (amount &lt; 0){
            double change;
            change = -amount;

            javax.swing.JOptionPane.showMessageDialog(this, "Your change is " + pounds.format(change / 100)

                    + coins (change), 
                    "change", JOptionPane.INFORMATION_MESSAGE);
        }
        else {
            javax.swing.JOptionPane.showMessageDialog(this, "Thank you, Exact Amount");
        }
    }
}



      String coins(double change) {
    String answer = ":";

    if (change &gt;= 4000) // give two £20 note change
    {
        answer += "\nTwo £20 note";
        change -= 4000;
    }
    if (change &gt;= 2000) // give a £20 note change
    {
        answer += "\nOne £20 note";
        change -= 2000;
    }
    if (change &gt;= 1500) // give £15 note change, a £10 note and a £5 note.
    {
        answer += "\nOne £10 note,\nOne £5 note ";
        change -= 1500;
    }
    if (change &gt;= 1000) // give a £10 note change
    {
        answer += "\nOne £10 note";
        change -= 1000;
    }
    if (change &gt;= 500) // give a £5 note change
    {
        answer += "\nOne £5 note";
        change -= 500;
    }
</code></pre>
