1 /**
2 * A class to test a CashRegister class.
3 */
4
5 public class CashRegisterTester {
6
7 public static void main(String[] args) {
8 CashRegister register = new CashRegister();
9 double price1, price2;
10 double payment;
11 price1 = 29.50;
12 price2 = 9.25;
13 payment = 50.00;
14
15 register.recordPurchase(29.50);
16 register.recordPurchase(9.25);
17 register.enterPayment(50);
18
19 double change = register.giveChange();
20 System.out.printf("Your change is %.2f. Have a nice day!\n", change);
21
22 System.exit(0);
23 }
24 }
Note: After line 16, this program cannot access the total purchase amount although it is stored in the member
register.purchase
because purchase is private.