Java Reference
In-Depth Information
143
ch04/cashregister/CashRegister.java
1 /**
2 A cash register totals up sales and computes change due.
3 */
4 public class CashRegister
5 {
6 /**
7 Constructs a cash register with no money in it.
8 */
9 public CashRegister()
10 {
11 purchase = 0 ;
12 payment = 0 ;
13 }
14
15 /**
16 Records the purchase price of an item.
17 @param amount the price of the
purchased item
18 */
19 public void recordPurchase( double amount)
20 {
21 purchase = purchase + amount;
22 }
23
24 /**
25 Enters the payment received from the customer.
26 @param dollars the number of dollars in the payment
27 @param quarters the number of quarters in the
payment
28 @param dimes the number of dimes in the payment
29 @param nickels the number of nickels in the payment
30 @param pennies the number of pennies in the
payment
31 */
32 public void enterPayment( int dollars,
int quarters,
33 int dimes, int nickels, int
pennies)
34 {
Search WWH ::




Custom Search