variable becomes 0 when used inside a method
<p>Here's the driver code. </p>

<pre><code>package javaPackage;

public class Driver{
    public static void main(String args[]){
        MobilePhone mp = new MobilePhone();
        mp.load(34.50);
        mp.call(3);
        mp.sendTextMessages();
        mp.printSummary();    
        System.out.println(mp.getNumTextMessages());
        System.out.print("Total minutes called: "+mp.totalMinutesCalled); 
    }
}
</code></pre>

<p>Here's the mobilePhone class.</p>

<pre><code>package javaPackage;

public class MobilePhone {
    double creditsLeft;
    int totalMinutesCalled;
    double ratePerCall;
    int textMessagesSent;

    public MobilePhone(){
        creditsLeft=0;
        totalMinutesCalled=0;
        ratePerCall=6.50;
        textMessagesSent=0;
    }   
    public void call(int minutes)   {
        totalMinutesCalled=minutes; 
    }

    public int getTotalMinutesCalled(){
        return totalMinutesCalled;
    }   
    public  void load( double pesos )   {
        creditsLeft=pesos-(ratePerCall*totalMinutesCalled);
    }
    public void changeRate(double newCallRate)  {
        ratePerCall=newCallRate;
    }
    public void sendTextMessages(){ 

        if(creditsLeft&gt;0){
        textMessagesSent++;
        creditsLeft--;
        }
        else
        {
            System.out.println("Not enough balance");
        }
    }
    public int getNumTextMessages()
    {   
        return textMessagesSent ;
    }   
    public void printSummary()  {
        System.out.println("Credits left:"+ (creditsLeft));
        System.out.println("Total call duration:" +totalMinutesCalled);
        System.out.println("Rate per call:"+ ratePerCall);
        System.out.print("Numer of text messages sent:" );
    }   
}
</code></pre>

<p>I have set <code>totalMinutesCalled</code> to <code>3</code>, but when I use <code>totalMinutesCalled</code> in the method <code>load()</code> to calculate the remaining credits, <code>totalMinutesCalled</code> becomes <code>0</code> so I can't get the results needed. When I display the totalMinutesCalled outside the <code>load()</code> method, oddly, it shows the correct value. Why is that?</p>

<p>Output</p>

<pre><code>Credits left:33.5
Total call duration:3
Rate per call:6.5
Numer of text messages sent:1
Total minutes called: 3
</code></pre>

<p>Thanks in advance!</p>