Advertisement
Guest User

Untitled

a guest
Mar 28th, 2020
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. //CheckingAccount.java
  2.  
  3. //Implementation of CheckingAccount class
  4.  
  5. //that extends BankAccount
  6.  
  7. Public Class CheckingAccount{
  8.  
  9. //Declaration of FEE as double type variable
  10.  
  11. //set the initial value as 15 cents
  12.  
  13. private final static double FEE=0.15;
  14.  
  15. //Implementation of Parameterized constructor
  16.  
  17. //with parameters name as string type and amount as double type
  18.  
  19. public CheckingAccount(String name,double begBal) {
  20.  
  21. super(name,begBal);
  22.  
  23. //call setAccountNumber function perform an operation
  24.  
  25. //accountNumber concatenated with –10
  26.  
  27. super.setAccountNumber(getAccountNumber()+"-10");
  28.  
  29. }
  30.  
  31. //Implementation of withdraw function
  32.  
  33. //This method will deduct the Monthly FEE
  34.  
  35. public boolean withdraw(double amount)
  36.  
  37. {
  38.  
  39. boolean boolValue=false;
  40.  
  41. //check amount is greater than 100
  42.  
  43. if(amount>100 && getBalance()+FEE>=amount)
  44.  
  45. {
  46.  
  47. super.withdraw(amount+FEE);
  48.  
  49. //Display statement
  50.  
  51. System.out.printf("After withdrawl of $%.2f, balance = %.2f\n",amount,getBalance());
  52.  
  53. boolValue=true;
  54.  
  55. }
  56.  
  57. //check balance is greater than amount
  58.  
  59. else if(getBalance()>=amount)
  60.  
  61. {
  62.  
  63. //call withdraw function of super class
  64.  
  65. super.withdraw(amount+FEE);
  66.  
  67. //Display statement
  68.  
  69. System.out.printf("After withdrawl of $%.2f, balance = %.2f\n",amount,getBalance());
  70.  
  71. boolValue=true;
  72.  
  73. }
  74.  
  75. else
  76.  
  77. {
  78.  
  79. //assign boolValue = false
  80.  
  81. boolValue=false;
  82.  
  83. }
  84.  
  85. return boolValue;
  86.  
  87. }
  88.  
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement