/** * A cash register totals up sales and computes change due * * @author Anne DeFrance * @version September 21, 2005 */ public class CashRegister { // instance variables private double totSpent; private double totPaid; // constructor with no args CashRegister() { totSpent = 0.0; totPaid = 0.0; } // end constructor public double getTotSpent() // I added this after class { return totSpent; } // in case the customer wants a subtotal public void ringUpItem(double cost) { totSpent = totSpent + cost; } // end ringUP public void amtPaid(double amt) { totPaid = totPaid + amt; } // end amt paid public double changeNeeded() { return totPaid - totSpent; } // end change needed public String toString() { String temp = ""; temp = "\n\tYour total purchases so far are " + totSpent; temp = temp + "\n\tYour payment so far is " + totPaid + "\n"; return temp; } }