Advertisement
semsem_elazazy

Untitled

May 24th, 2022
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.32 KB | None | 0 0
  1. package package1;
  2.  
  3. import java.util.*;
  4.  
  5. public class Account {
  6.  
  7. ArrayList<Transactions> List2= new ArrayList<Transactions>();
  8.  
  9. //Variables
  10.  
  11. protected String date;
  12. protected String name;
  13. protected int Account_num;
  14. protected double AnuualInterestRate;
  15. protected double Balance;
  16.  
  17. // constructors
  18. public Account () {}
  19.  
  20. public Account (int Date, String name, int Account_num, int Balance ,Double AnuualInterestRate) {
  21. this.name=name;
  22. this.AnuualInterestRate=AnuualInterestRate;
  23. this.Balance=Balance;
  24. this.Account_num=Account_num;
  25.  
  26. }
  27.  
  28. // getters and setters
  29.  
  30. public String getDate() {
  31. return date;
  32. }
  33. public void setDate(String date) {
  34. Scanner in = new Scanner(System.in);
  35. System.out.println("Enter the Date ");
  36. date = in.nextLine();
  37. }
  38. public String getName() {
  39. return name;
  40. }
  41. public void setName(String name) {
  42. Scanner in = new Scanner(System.in);
  43. System.out.println("Enter the Name ");
  44. name = in.nextLine();
  45. }
  46. public int getAccount_num() {
  47. return Account_num;
  48. }
  49. public void setAccount_num(int account_num) {
  50. Scanner in = new Scanner(System.in);
  51. System.out.println("Enter the ID ");
  52. account_num = in.nextInt();
  53. }
  54. public double getAnuualInterestRate() {
  55. return AnuualInterestRate;
  56. }
  57. public void setAnuualInterestRate(double anuualInterestRate) {
  58. Scanner in = new Scanner(System.in);
  59. System.out.println("Enter the AnuualInterestRate ");
  60. anuualInterestRate = in.nextDouble();
  61. }
  62. public double getBalance() {
  63. return Balance;
  64. }
  65. public void setBalance(double balance) {
  66. Scanner in = new Scanner(System.in);
  67. System.out.println("Enter the AnuualInterestRate ");
  68. balance = in.nextDouble();
  69. }
  70.  
  71. //Transactions Methods
  72.  
  73. //1)withdraw
  74. public double Withdrawal(double amount) {
  75. if(Balance< amount) {
  76. System.out.println("Invalid Amount");
  77. }
  78. else if (amount > 8000) {
  79. System.out.println("Invalid");
  80. }
  81. else {
  82. Transactions t = new Transactions(new Date (), amount,'W');
  83. List2.add(t);
  84.  
  85. Balance -=amount;
  86. }
  87. return Balance;
  88. }
  89.  
  90. //2)deposit
  91.  
  92. public double Deposit(double amount) {
  93. Transactions t = new Transactions(new Date (), amount,'D');
  94. List2.add(t);
  95. Balance += amount;
  96. return Balance;
  97. }
  98.  
  99. //3)AnnualInterestRate
  100. public double AnuualInterestRate() {
  101. Transactions t = new Transactions(new Date (),'R');
  102. List2.add(t);
  103. Balance +=(Balance *0.015);
  104. return Balance ;
  105. }
  106.  
  107.  
  108. //Display Methods
  109.  
  110. //1) Transactions
  111. void DisplayTransactions() {
  112. for(int i=0 ; i<List2.size() ; i++) {
  113. System.out.println(List2.get(i).date +" "+List2.get(i).transaction +" " + List2.get(i).amount);
  114. }
  115. }
  116. //2)Account
  117. void DisplayAccountInformation() {
  118. System.out.println("Customer Name : "+name );
  119. System.out.println("ID : "+Account_num );
  120. System.out.println("Date : "+date );
  121. System.out.println("Current Balance : "+Balance );
  122. System.out.println("\n");
  123. System.out.println("------------------After Transaction------------------");
  124. DisplayTransactions();
  125.  
  126.  
  127. }
  128.  
  129.  
  130. }
  131.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement