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 public methods:
void recordPurchase(double amt)
void enterPayment(double amt)
double giveChange()
A CashRegister instance stores the total dollar amount of all purchases until payment is made in the private member purchase. For each call to recordPurchase, this total is updated.
When enterPayment is called, another CashRegister private member, payment, stores the amount of the payment.
Finally when giveChange is called, the change is calculated (payment - purchase) and is returned.