Local variables in the method main declared as the basic type double:
price1, price2, payment and change
The call stack is storage for local variables of methods.
Storage for local variables is allocated on the top of the stack when a method begins and is removed from the top of the stack when the method finishes (returns).
Local variable register is of type CashRegister which is a user defined class type.
A class type has methods that can be called that require a value of that type plus 0 or more additional parameters. The number of parameters depends on the particular method.
The user defined CashRegister type has these methods:
void recordPurchase(double amt) void enterPayment(double amt) double giveChange()
A CashRegister value instance stores the total dollar amount of all purchases until payment is made. For each call to recordPurchase, this total is updated.
When enterPayment is called, another CashRegister value stores the amount of the payment.
Finally when giveChange is called, the change is calculated (payment - total_purchase) and is returned.