daily pastebin goal
25%
SHARE
TWEET

Untitled

a guest Dec 7th, 2018 61 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1.  
  2. /**
  3.  * A cash register totals up sales and computers change due.
  4.  */
  5. public class CashRegister
  6. {
  7. public CashRegister()
  8. {
  9.    purchase = 0;
  10.    payment = 0;
  11. }
  12.  
  13. public void recordPurchase(double amount)
  14. {
  15.     purchase = purchase + amount;
  16. }
  17.  
  18. public static void main(String args[])
  19. {
  20. }
  21. public void enterDollars(int dollars)
  22.     {
  23.         payment = payment + dollars;
  24.     }
  25. public void enterQuarters(int quarters)
  26.     {
  27.         payment = payment + quarters *QUARTER_VALUE;
  28.     }
  29.    
  30. public double giveChange()
  31.     {
  32.         double change = payment - purchase;
  33.         purchase = 0;
  34.         payment = 0;
  35.         return change;
  36.     }
  37.    
  38. public static final double QUARTER_VALUE = 0.25;
  39. public static final double DIME_VALUE = 0.1;
  40. public static final double NICKLE_VALUE = 0.05;
  41. public static final double PENNY_VALUE = 0.01;
  42.  
  43. private double purchase;
  44. private double payment;
  45. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top