View Single Post
  #2 (permalink)  
Old 08-07-2007, 07:08 AM
coco coco is offline
Member
 
Join Date: Jul 2007
Posts: 39
coco is on a distinguished road
You are getting an error about the fixedcents variable in your toString method because fixedcents no longer exists.

Fixedcents is declared in your add() method. Any variable that is declared in a method is freed/garbage collected when that method terminates. Hence why you have dollars, cents, and increase declared at the top of your file outside of any method. If you want fixedCents to exist for all your methods declare it with dollars, cents and increase.

I should mention that at second glance, I don't see where you've declared FixedCents at all... Thus, my above comment may or may not be correct.

Why don't you just change every instance of fixedCents to cents?
Example

Code:
public int add(){ cents = cents + increase; if (cents > 99){ dollars + 1; cents-100; } } public String toString(){ return dollars+"."+cents; }
Greetings.
Reply With Quote