Advertisement
Guest User

Untitled

a guest
Feb 27th, 2015
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1.  
  2. public abstract class Account {
  3. protected double balance = 0;
  4.  
  5. int acctNo;
  6. Random rand = new Random();
  7.  
  8. public Account()
  9. {
  10.  
  11. }
  12.  
  13.  
  14.  
  15. public Account(double ebalance)
  16. {
  17. balance = ebalance;
  18. acctNo = rand.nextInt(10000);
  19. }
  20.  
  21.  
  22. public String toString()
  23. {
  24.  
  25. return ("Account Number: " + acctNo + "\n" + "Balance: " + balance);
  26. }
  27. public double deposit(double amount)
  28. {
  29.  
  30. balance = balance + amount;
  31. return balance;
  32. }
  33. public abstract double withdraw(double withdraw);
  34.  
  35.  
  36.  
  37. }
  38.  
  39. public class CheckingAccount extends Account{
  40. int overDraftFee = 10;
  41. double balance;
  42. final double MINIMUMBALANCE = 100;
  43.  
  44. public CheckingAccount()
  45. {
  46.  
  47. }
  48.  
  49. public CheckingAccount(double eDeposit)
  50. {
  51. super(eDeposit);
  52.  
  53. }
  54. public double deposit(double aDeposit)
  55. {
  56. super.deposit(aDeposit);
  57. return balance;
  58.  
  59. }
  60.  
  61. public double withdraw(double withdraw)
  62. {
  63.  
  64. balance = balance - withdraw;
  65.  
  66. if (balance < 0)
  67. {
  68. System.out.println("You have overdrawn your account.");
  69. System.out.println("Overdraft fee is 10.00");
  70. balance= balance - overDraftFee;
  71.  
  72. return balance;
  73. }
  74. else
  75. {
  76. return balance;
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement