I want to be able to allow for an increase in cents, but obviously I don't want people to be able to have 15dollars and 190cents because that's just not how it is supposed to be. Can anyone give me some tips on how to properly express adding to dollars and subtracting to cents when my cents > 99?
Also eclipse is giving me an error when i try and add fixedCents in my toString method. How do i write it so that I get the fixedCents variable from the add method?
public class USDollars {
private int dollars;
private int cents;
private int increase;
public USDollars(int dollars, int cents, int increase){
this.dollars = dollars;
this.cents = cents;
this.increase = increase;
}
public int add(){
fixedCents = cents + increase;
if (fixedCents > 99){
dollars + 1;
fixedCents-100;
}
}
public String toString(){return dollars+"."+fixedCents;}
}
Thanks.