Advertisement
Guest User

Untitled

a guest
Sep 27th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1.  
  2. /**
  3. * Write a description of class BankAccount here.
  4. *
  5. * @author (your name)
  6. * @version (a version number or a date)
  7. */
  8. public class BankAccount
  9. {
  10. private double balance;
  11. public String accountHolder;
  12. public String accountNumber;
  13. public BankAccount () //constructor
  14. {
  15. balance = 0; //initialize to 0
  16. accountHolder = "";
  17. accountNumber = "";
  18. }
  19.  
  20. //you should name all methods with lowercase
  21. //void = no return value
  22. //depositAmount is the amount to be deposited
  23. public void deposit (double depositAmount)
  24. {
  25. balance = balance + depositAmount; //old balance + deposit amount
  26. }
  27.  
  28. //updates balance if withdraw value is less than balance, otherwise return 0 if not enough money in balance
  29. public double withdraw (double withdrawAmount)
  30. {
  31. if (balance >= withdrawAmount)
  32. {
  33. balance = balance - withdrawAmount; //old balance - withdraw amount
  34.  
  35. return withdrawAmount;
  36. }
  37. else
  38. return 0;
  39. }
  40.  
  41. public void printStatement ()
  42. {
  43. System.out.println("Your balance is " +balance);
  44. }
  45.  
  46. public double getBalance()
  47. {
  48. return balance;
  49. }
  50.  
  51.  
  52. }
  53.  
  54. //initalize the l and w to 1
  55. //getlength set length setwidth
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement